473,326 Members | 2,108 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,326 software developers and data experts.

Context menu needs to be popped from many controls

I have a usercontrol on which I have, say, five controls.

I want a context menu to popup when the mouse is clicked anywhere on the
userconttrol.

The same context menu.

What I've done in the past is to put code in each control's mouseup event.

Is that the way to go or is there a better way?

Thanks

Nov 21 '05 #1
3 1162
Make a single sub that you call from each mouseclick event. Or if the
control's mouseclick events have the same function prototype (which they
probably do) you can just add handlers onto the same function

Sub Generic_MouseCick(Sender as object, .......) handles
Control1.MouseClick, Control2.MouseClick
'Popup
End sub

You could also use the Addhandler function to do it instead of the handles
keyword.

Chris
" Just Me" <gr****@a-znet.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have a usercontrol on which I have, say, five controls.

I want a context menu to popup when the mouse is clicked anywhere on the
userconttrol.

The same context menu.

What I've done in the past is to put code in each control's mouseup event.

Is that the way to go or is there a better way?

Thanks

Nov 21 '05 #2

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:et**************@TK2MSFTNGP11.phx.gbl...
Make a single sub that you call from each mouseclick event. Or if the
control's mouseclick events have the same function prototype (which they
probably do) you can just add handlers onto the same function

Sub Generic_MouseCick(Sender as object, .......) handles
Control1.MouseClick, Control2.MouseClick
'Popup
End sub
Good, Thanks a lot

You could also use the Addhandler function to do it instead of the handles
keyword.

Chris
" Just Me" <gr****@a-znet.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have a usercontrol on which I have, say, five controls.

I want a context menu to popup when the mouse is clicked anywhere on the
userconttrol.

The same context menu.

What I've done in the past is to put code in each control's mouseup
event.

Is that the way to go or is there a better way?

Thanks


Nov 21 '05 #3
" Just Me" <gr****@a-znet.com> schrieb:
I have a usercontrol on which I have, say, five controls.

I want a context menu to popup when the mouse is clicked anywhere on the
userconttrol.

The same context menu.

What I've done in the past is to put code in each control's mouseup event.

Is that the way to go or is there a better way?


Yes, assigning it to the controls' 'ContextMenu' property. This will allow
the menu to popup when the context menu key is pressed.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ira Gladnick | last post by:
I would like to determine the screen position of a context menu (or possibly one of the items in the context menu) when it is popped up, in order to position the mouse cursor on the menu. Have...
4
by: Aaron Queenan | last post by:
How can I use the designer to add a context menu to a class which inherits from a control, e.g. treeview, without adding the context menu to a form? For example, to add a context menu with...
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
0
by: Andrew Baker | last post by:
Have a look at the code below. It's a really simple example where I have added two controls to a form, a textbox and a combo box. Both add owner drawn context menus to the controls, but the...
3
by: PJ Olson | last post by:
I have a context menu associated with a tray icon. On the context menu, I have a menuitem that is populated with sub menuitems at run time. When the user right-clicks the tray icon I populate the...
4
by: Don Peters | last post by:
I can't seem to find an answer to this problem in spite of many searches. I have a VB.NET program that has a context menu popup event. In it I associate some menu items with their events, as...
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
2
by: Paul E Collins | last post by:
A context menu is created in the scope of the RightClick event, but it continues to be displayed after that event handler terminates - i.e. after it has gone out of scope. The code works correctly,...
2
by: Lucky | last post by:
hi guys, i'm working on the context menu for the controls. the problem i'm facing right now is like this : i want to use one context menu for more then one controls lets say i want to use one...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.