Is it possible and if so, how, to programmatically select non-consecutive rows in a standard WinForms datagrid?
foreach (var selectableRowIndex in selectableRowIndices)
{
dataGridView.Rows[selectableRowIndex ].Selected = true;
}
… does work, but after setting the dataGridView’s .CurrentCell Property via
dataGridView.CurrentCell = dataGridView.Rows[underlyingRowIndex].Cells[1];
all other rows get deselected.
What’s the proper way to set the current row/cell and keep other rows selected?
a quick and dirty solution would be:
-get the IDs of the currently selected rows
-change the current cell
-re-select the rows