Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the parent control from an assigned context menu using C#?

I have a few listview controls on a windows form and i've assigned a common contextmenustrip to them all using the properties grid in VS2005.

Now when a selection is made from the contextmenu in any listview, is there a way i can get the correct hosting control of the raised menu?

like image 909
Gary Willoughby Avatar asked Nov 23 '08 22:11

Gary Willoughby


People also ask

What is a ContextMenu How would you attach a ContextMenu to a control?

A ContextMenu is attached to a specific control. The ContextMenu element enables you to present users with a list of items that specify commands or options that are associated with a particular control, for example, a Button. Users right-click the control to make the menu appear.

How does ContextMenu differ from main menu in VB net?

The ContextMenu class represents shortcut menus that can be displayed when the user clicks the right mouse button over a control or area of the form. Shortcut menus are typically used to combine different menu items from a MainMenu of a form that are useful for the user given the context of the application.


1 Answers

ContextMenuStrip.SourceControl

like image 100
Mladen Prajdic Avatar answered Sep 30 '22 10:09

Mladen Prajdic