我在这里有一个示例 C# windows 窗体。单击鼠标左键时,我需要显示通知图标的上下文菜单。我已经标记了在哪里编写所需的代码,如下所示:
private void button1_Click(object sender, EventArgs e)
{
//Need to show the context menu here
}
请帮忙!
我在这里有一个示例 C# windows 窗体。单击鼠标左键时,我需要显示通知图标的上下文菜单。我已经标记了在哪里编写所需的代码,如下所示:
private void button1_Click(object sender, EventArgs e)
{
//Need to show the context menu here
}
请帮忙!
左键单击图标时显示菜单
private void NotifyIcon_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
MethodInfo methodInfo = typeof(NotifyIcon).GetMethod("ShowContextMenu",
BindingFlags.Instance | BindingFlags.NonPublic);
methodInfo.Invoke(this.notifyIcon, null);
}
}
单击问题中的按钮时显示菜单
private void button1_Click(object sender, EventArgs e)
{
//Need to show the context menu here
MethodInfo methodInfo = typeof(NotifyIcon).GetMethod("ShowContextMenu",
BindingFlags.Instance | BindingFlags.NonPublic);
methodInfo.Invoke(this.notifyIcon, null);
}