I have a dataGridView
and I need that when the user clicks on any cell the whole row that contains this cell is selected too. (it has multiselect disbaled)
I tried getting the currentRowIndex
like this
int Index = dataGridView1.CurrentCell.RowIndex;
However, I am not sure how to use the index in order to select that row. Tried this and about other six ways with no success:
dataGridView1.Select(Index);
Do you know a way I can do this?
You need to set datagridview's SelectionMode
to FullRowMode
.
Note: In Visual Studio 2013 with .NET 4.5 the property is called FullRowSelect
, see https://msdn.microsoft.com/en-us/library/3c89df86(v=vs.110).aspx