You could keep track of whichever cell was last clicked by adding an event handler for the DataGridView's mouse click.
Something like:
DataGridViewCell clickedCell;
private void dataGridView1_CellMouseClick_1(object sender, DataGridViewCellMouseEventArgs e)
{
try
{
DataGridView view = (DataGridView)sender;
if (e.Button == System.Windows.Forms.MouseButtons.Right && e.RowIndex >= 0)
{
Console.WriteLine("Clicked column "
+ e.ColumnIndex + ", row "
+ e.RowIndex + " of DataGridView "
+ view.Name + " at "
+ System.Windows.Forms.Cursor.Position);
clickedCell = view.Rows[e.RowIndex].Cells[e.ColumnIndex];
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
}
}
Then in your contextMenuStripItem click event, switch on clickedCell.Value like:
switch (clickedCell.Value)
{
case "Copy":
break;
... // etc.
}