PC Review


Reply
Thread Tools Rate Thread

Context menu needs to be popped from many controls

 
 
Just Me
Guest
Posts: n/a
 
      19th Jan 2005
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



 
Reply With Quote
 
 
 
 
Chris, Master of All Things Insignificant
Guest
Posts: n/a
 
      19th Jan 2005
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" <(E-Mail Removed)> wrote in message
news:%23Ot2jVl$(E-Mail Removed)...
>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
>
>
>



 
Reply With Quote
 
Just Me
Guest
Posts: n/a
 
      19th Jan 2005

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:et41ZZl$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%23Ot2jVl$(E-Mail Removed)...
>>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
>>
>>
>>

>
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      19th Jan 2005
" Just Me" <(E-Mail Removed)> 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/>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Context menu with multiple controls mick Microsoft C# .NET 1 29th Jul 2009 11:14 PM
Common Context menu for two controls bob Microsoft C# .NET 1 30th Sep 2007 08:46 PM
How to use context menu in treeview (for web form, ie web controls)? Xprata via DotNetMonster.com Microsoft ASP .NET 0 27th Dec 2004 05:13 PM
context menu and controls Bernie Yaeger Microsoft VB .NET 3 26th Dec 2004 10:54 PM
Controls Sharing a Context Menu jcrouse Microsoft VB .NET 3 30th Jun 2004 06:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:27 PM.