views:

1669

answers:

2

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
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
Yes, you're absolutely right. My mistake.
Stu Mackellar
+1  A: 

SourceControl property on the ContextMenuStrip class will show the last control that caused that menu strip to be shown.

Binary Worrier