I have two different grid controls on the same form. They share the same context menu. I am having trouble determining which control is the owner when I select the context menu item.
A:
The event handler for the MenuItem's Click event will have a Sender parameter. This object should be the control that had the focus when the context menu was displayed.
Stu Mackellar
2008-10-28 16:56:20
Sorry but all that will give you is a reference to the actual menu item that was clicked, not the control that was right clicked to fire the context menu.
Binary Worrier
2008-10-28 17:23:59
Yes, you're absolutely right. My mistake.
Stu Mackellar
2008-10-29 13:32:30
+1
A:
SourceControl property on the ContextMenuStrip class will show the last control that caused that menu strip to be shown.
Binary Worrier
2008-10-28 17:20:55