I have a DataGridView linked to a ContextMenuStrip. The DataGridView is populated. I select a row (any cell) and when I right click, it opens a menu, where I can choose Edit, Rename or Delete. How can I pass the row number of the selected row to my ContextMenuStrip? So, I left click to select a cell in Row Number 2. I right click anywhere on the DataGridView and I select "Rename". I want to get a message "you want to rename row number 2". It would be ok to right-click directly on row number 2 and get the message (without first selecting a cell on row number 2).Here is my attempt of code:
void RenameToolStripMenuItemClick(object sender, EventArgs e)
{ //this should rename the table
MessageBox.Show("This should rename the selected row number " + dataGridView1.SelectedRows.ToString());
}