Question

I'm having a ContextMenu, and I need to determine what control has it been opened on in the event ContextMenu_Opening.

The event arguments do not contain such information, or either the sender. How can I do that?

Was it helpful?

Solution

Solved by using a simple property which I had no idea it existed..:

private void contextMenu1_Opening(object sender, CancelEventArgs e)
{
     MessageBox.Show(contextMenu1.SourceControl.Name);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top