How to show a Context Menu when you right click a Menu Item in a DataGridView ? I would like to add delete in the menu so that the entire row can be deleted . Thanks in Ad
I know this question is quite old, but maybe someone will still have use for this. There is an Event for this, CellContextMenuStripNeeded. The following code works perfectly for me and seems less hacky than the MouseUp Solution:
private void DGV_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
{
if (e.RowIndex >= 0)
{
DGV.ClearSelection();
DGV.Rows[e.RowIndex].Selected = true;
e.ContextMenuStrip = MENUSTRIP;
}
}