Context menu needs to be popped from many controls

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

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
 
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
 
Chris said:
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
 
Just Me said:
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.
 
Back
Top