I have single ContextMenuStrip
attached to two controls (DataGridView
).
In the ToolStripMenuItem
click event, I manage to get the original caller (the DataGridView
) with this code :
var menu = (ToolStripDropDownItem)sender;
var strip = (ContextMenuStrip)menu.Owner;
var dgv = (DataGridView)strip.SourceControl;
It works pretty good when I click on my ToolStripMenuItem
.
But when I use the sortcut key linked to the ToolStripMenuItem
, the strip.SourceControl
return null.
Does anyone know why ?