I have a winform with multiple PictureBox controls on it. I have a context menu which is attached to all of these PictureBox controls. I have 3 submitems (menus) in the context menu which should be displayed in right click on any of the PictureBox instances and that works fine.
Now, before the context menu pop ups, I need to check the properties of PictureBox where it is clicked to enable or disable certain sub menus.
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
}
I see this event, but the sender object is a reference of ContextMenu. I need the PictureBox parameter to do this.
I haven’t tried this but you might want to look at the
SourceControlproperty of theContextMenu(sender).It should have a reference to the actual control the
ContextMenuis being displayed for.The MSDN page I linked to also has a sample that I think will be helpful. They are listening to the
Popupevent though, but it should be the same.