Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ContextMenuStrip...How Do I Know The Context? 1

Status
Not open for further replies.

gharabed

Programmer
Sep 7, 2001
251
US
I've set the ContextMenuStrip property of a widget so that when I right click on the widget, a context menu appears. How do I tell the name and type of the underlying widget from inside the selected menu item when the item is selected? For example, say I have a button (Button10) that I associate a context menu strip with that contains two items. If I right click on the button, the menu pops up. I select "item 2" and handle that using the "MenuItem2_Click" event. How do I tell the underlying object (the context) for the menu is Button10? Hopefully that makes sense.
Thanks,
Greg
 
Using your button example, one way to achieve this would be to use something like this:
Code:
Dim mnuParent As ContextMenuStrip = MenuItem2.GetCurrentParent
MessageBox.Show(mnuParent.SourceControl.Name)
Hope this helps

Andy
---------------------------------
[green]' Signature removed for testing purposes.[/green]

 
Yep, I actually figured it out. It works great. Thanks for the reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top