I want to share a ContextMenuStrip between two DataGridViews - i.e. DataGridView.ContextMenuStrip = whatever
In the ToolStripMenuItem.Click handler I can determine the associated DataGridView by using this code (which I derived from a three year old post found here!) ...
Dim c As ContextMenuStrip = DirectCast(DeleteToolStripMenuItem.GetCurrentParent, ContextMenuStrip)
If TypeOf c.SourceControl Is DataGridView Then
Dim Grid As DataGridView = DirectCast(c.SourceControl, DataGridView)
MsgBox(Grid.Name & " / " & Grid.CurrentCell.Value.ToString)
But so far I am not able to determine the cell. The CurrentCell.Value is for 0,0. I have been looking through all of the properties in the debugger and several look promising but so far I have found nothing indicating which cell the right click occurred in.
So if anyone knows and would share I would be grateful. You would be saving me a lot of work.
Thanks, Bob