I'm trying to make a NotifyIcon
display a context menu, even if it's clicked with the left mouse button. I can get it to display in the correct location with this in the icon's MouseDown
event:
sysTrayIcon.ContextMenuStrip = TrayContextMenu
If e.Button = MouseButtons.Left Then TrayContextMenu.Show()
But because sysTrayIcon
isn't specified as the control when I left click, it doesn't clear from the screen if I click outside the menu or press escape.
I know the usual method is to use the menu's overloaded Show(control, location)
method, but that's raising this error:
Value of type 'System.Windows.Forms.NotifyIcon' cannot be converted to 'System.Windows.Forms.Control'.
So how can I attach the menu to the notify icon, please?