Invoke NotifyIcon's Context Menu

后端 未结 4 698
陌清茗
陌清茗 2020-11-29 04:32

I want to have it such that left clicking on the NotifyIcon also causes the context menu (set with the ContextMenuStrip property) to open as well. How would I achieve this?

4条回答
  •  旧巷少年郎
    2020-11-29 05:06

    If you handle MouseUp rather than Click, you will be able to tell which button was clicked, as well as the location of the click. You can use this location as the location to show the ContextMenu

    notifyIcon.MouseUp += new MouseEventHandler(delegate(object sender, MouseEventArgs e) { contextMenu.Show(e.Location); });
    

提交回复
热议问题