I want to obtain a list of the row indices of selected cells in a DataGridView.
I was previously using SelectedCells
to get this information, but this takes around 40 seconds when there are 2 million rows and all are selected.
this.SelectedCells
.Cast<DataGridViewCell>()
.Select(c => c.RowIndex)
On Msdn it says that SelectedCells
is slow for large grids, but apart from the special case where all cells happen to be selected, does not offer many alternatives. What if all but 1 row/cell is selected?
Is there a faster method?