Left Click Context Menu

Use this board to post your code snippets - tips and tricks
3 posts Page 1 of 1
Contributors
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 444
Joined: Tue Feb 16, 2010 6:24 am

Left Click Context Menu
Livengood
hey guys,
well today i have found an older code, even know it didnt work at frist but i have fixed it :D.
this code helps opening context menu's on a left click. Frist off take the item you want this to be on, and get the private sub [Mouse Click]

Example :
Code: Select all
Private Sub SearchPic_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SearchPic.MouseClick
End Sub
and then add this code
Code: Select all
Dim x As Integer
        Dim y As Integer
        x = Windows.Forms.Cursor.Position.X - Me.Location.X - 5
        y = Windows.Forms.Cursor.Position.Y - Me.Location.Y - 23
        Dim xy As New Point(x, y)
        [context menu name].Show(Me, xy)
Image
User avatar
Agust1337
Coding God
Coding God
Posts: 2456
Joined: Fri Feb 19, 2010 8:18 pm

Re: Left Click Context Menu
Agust1337
Hey just so everyone know's theres a one line code for this if you mean the ContextMenu System Styled one then:

go to Form_load:
Code: Select all
'heres an example with listview:
ListView1.ContextMenu = ContextMenu1
:)
You're crazy!
I'm not crazy, my mother had me tested. ~Sheldon Cooper
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Left Click Context Menu
Codex
agust1337 wrote:
Hey just so everyone know's theres a one line code for this if you mean the ContextMenu System Styled one then:

go to Form_load:
Code: Select all
'heres an example with listview:
ListView1.ContextMenu = ContextMenu1
:)
thats for the right click... the one he shows above is for left click ... :lol:
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
3 posts Page 1 of 1
Return to “Quick Snips”