You can reference a grid like an array:
ProductsGrid[ProductsGrid.SelectedColumns[0].Index, ProductsGrid.SelectedRows[0].Index].Value;
Selecting indexes from the first index of SelectedRowsCollection and SelectedColumnsCollection, you will get the first value if multiple rows are selected.
You can block the user from selecting only one row by setting the MultiSelect property in the DataGridView. Alternatively, you make the CellClick event:
ProductsGrid.ClearSelection(); ProductsGrid.Rows[e.RowIndex].Selected = true;
Greg buehler
source share