I'm trying to figure how if it's possible to completely deselect rows, including the arrow symbol in the rowheader cell.
The reason I am trying to do this is because with multiple selections (eg. using CTRL key) the user can select multiple rows, but they can also deselect previous selections.
Example:
- Select first 3 rows with CTRL key
- Deselect 3rd row with CTRL key. The SelectedRows collection correctly reflects the change, and now contains only the first 2 rows. Also, the CurrentRow.Selected = false for the third row
- But the RowHeader arrow is still on the third row, which is now no longer selected
- What I would ideally like is to set the new CurrentRow to be the second row, and the RowHeader to be updated accordingly
I have tried the following:
DataGridViewSelectedRowCollection selRows = _dataGrid.SelectedRows;
bool selected = _currentRow.Selected;
if (selRows.Count > 0 && !selected)
{
//Get index of last row in selRows collection
RowIndex = selRows[selRows.Count - 1].Index;
//The following call results in selRows being cleared and only 1 row being
//selected
_dataGrid.CurrentCell = _dataGrid.Rows[RowIndex].Cells[0];
}
but it does not do what I need.
Any suggestions would be greatly appreciated.
Thanks
Mauro Ciaccio