473,395 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Popup Menu On Right Click

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
4 32058
"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
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
* "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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Anand Ganesh | last post by:
Hi All, When the user right clicks on the desktop or selects a file and right clicks the mouse he should see our own submenu along with the Windows context menu. How will I do this in Visual C#...
0
by: VM | last post by:
I'm having a synchronizaition problem when I display a right-click popup mouse and when I have the code that checks where in the row the user clicked in order to mark the whole line. With the...
12
by: Veeresh | last post by:
In my asp.net application I want to block mouse right click on my web pages. That means instead of popup menu I may just display some message or no message at all. Hot to do that? Thanks, Veer
1
by: Juan Romero | last post by:
Hey guys, I have a small problem here.... I have a treeview control. I want to display a popup menu when the user right clicks on a node. This is no problem, and I am able to make the popup come...
5
by: Robert Smith | last post by:
Hello, I have often seen system tray icons that you click on and a popup menu appears. Is it possible to do this in Visual basic.net or are there any controls that allow this to be achieved. ...
11
by: Terry Olsen | last post by:
How can I catch a right-click on a DropDownMenuItem?
9
by: john | last post by:
In Paradox I was able to create popup menu's in which some of the items had popup menu's themselves. I've looked for threads on popup menu's and access but I can't find how to make a simple popup...
5
by: SQACSharp | last post by:
I'm trying to automate an action in Internet Explorer.... I'm trying to click an image that open a popup menu. The html code of the iimage look like like <img blabla..OnClick="ShowMenu()"/> I...
4
by: Jegan Mohan | last post by:
Dear Experts ! Design Pattern : Launch one website from another website .
1
by: Carl | last post by:
"Chuckk Hubbard" <badmuthahubbard@gmail.comwrites: Try creating the "main" popup menu before the sub-menus, and when instantiating the sub-menus, pass the main menu as the "master" instead of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.