Left click for notifyicon menu?

LeonR

Well-known member
Joined
Nov 2, 2006
Messages
139
Location
UK
Programming Experience
10+
Ive done some searches on the web and not found much.

Basically, I have a NotifyIcon contextmenu setup, which works fine for right click.

I simply want the same menu to pop up when I left click, ive got as far as this :-

NotifyIcon1.ContextMenu.Show(x, Control.MousePosition)


what do i use for "x" ? form1 is not used/visible.


Thanks! :)
 
Thanks for the info mate!

Well, as you guessed, if i do not hide form1/make it invisible, it does work.


However if i use me.hide and e.cancel=true i still get this error :-

Additional information: ContextMenu cannot be shown on an invisible control.


Its a bit strange, but im trying to *only* use a systemtray icon/menu, so i dont actually use any forms.
 
There are 6 overloads of Show method, you can use another.
VB.NET:
Private Sub NotifyIcon1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles NotifyIcon1.MouseClick
    If e.Button = Windows.Forms.MouseButtons.Left Then
        Me.Activate()
        NotifyIcon1.ContextMenuStrip.Show(Control.MousePosition, ToolStripDropDownDirection.Left)
    End If
End Sub
You also don't have to Hide the form, set it's WindowState=Minimized and ShowInTaskbar=False in designer and it won't show.
 
Thanks for that! :D


Fixed my issue!


Only problem i have now is using "ticks" on the ContextMenuStrip rather than ContextMenu. lol
 
Only problem i have now is using "ticks" on the ContextMenuStrip rather than ContextMenu. lol
like checkbox ticks? Add ToolStripMenuItem (MenuItem in designer) and set CheckOnClick=True, the Checked property can be set/read.
 
Well, before I was simply getting "ticks" showing beside text on the menu, which i would control. It was not somthing the user actually selected.

Any ideas? Or is what you suggested still the way?


Im struggling to explain it accuratly as im not too clued up in this area! :(

Basically, as before, i simply have some items on the menu, and i wish to present a "tick" next to the text/item when its clicked. :)


Cheers for help!
 
If you don't want user to check/uncheck it set CheckOnClick=False (default).
 
Back
Top