By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 974 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

Popup Menu On Right Click

P: n/a
I am trying to right click on a form and have a custom
popup menu display. Does anyone know how to do this in
vb.net.

Thanks!
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Randy" <an*******@discussions.microsoft.com> schrieb
I am trying to right click on a form and have a custom
popup menu display. Does anyone know how to do this in
vb.net.


Add a contextmenu from the toolbox. Assign in to the form's contextmenu
property.

See also:
http://msdn.microsoft.com/library/en...ccessories.asp

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
Drag a "ContextMenu" control onto your form in the designer, and edit it
like you would a menu (add items, etc). Then in your form, you can show it
like this:

Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
If e.Button = MouseButtons.Right Then
ContextMenu1.Show(Me, New Point(e.X, e.Y))
End If
End Sub
"Randy" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
I am trying to right click on a form and have a custom
popup menu display. Does anyone know how to do this in
vb.net.

Thanks!

Nov 20 '05 #3

P: n/a
* "Philip Rieck" <st***@mckraken.com> scripsit:
Drag a "ContextMenu" control onto your form in the designer, and edit it
like you would a menu (add items, etc). Then in your form, you can show it
like this:

Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
If e.Button = MouseButtons.Right Then
ContextMenu1.Show(Me, New Point(e.X, e.Y))
End If
End Sub


Why not assign the context menu to the form's 'ContextMenu' property?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

P: n/a
Herfried, you're right - ContextMenu would probably be better.

I'm so used to answering "when showing context menu, show x if
somecondition, else y", so I have this snippet (well, the snippit I based
this on) around for a quick answer. I also have one that sets the
contextmenu property of the form and reacts to the popup event to
enable/disable menu items - should have used and edited that one. Sorry for
any confusion.


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bu************@ID-208219.news.uni-berlin.de...
* "Philip Rieck" <st***@mckraken.com> scripsit:
Drag a "ContextMenu" control onto your form in the designer, and edit it
like you would a menu (add items, etc). Then in your form, you can show it like this:

Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
If e.Button = MouseButtons.Right Then
ContextMenu1.Show(Me, New Point(e.X, e.Y))
End If
End Sub


Why not assign the context menu to the form's 'ContextMenu' property?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.