I have two datagridviews, and when I click to one of them, I would like to deselect all selection in the second datagridview, I tried this, but nothing works:
firstItemsDataGridView.ClearSelection();
firstItemsDataGridView.CurrentCell = null;
not working,
firstItemsDataGridView.ClearSelection();
if (firstItemsDataGridView.Rows.Count > 0)
firstItemsDataGridView[1, 0].Selected = true;
firstItemsDataGridView.CurrentCell = null;
firstItemsDataGridView.ClearSelection();
foreach (DataGridViewRow item in firstItemsDataGridView.Rows) {
item.Selected = false;
foreach (DataGridViewCell itemCell in firstItemsDataGridView.Columns) {
itemCell.Selected = false;
}
}
not working,
firstItemsDataGridView.Rows[0,-1].Selected = true;
not working too.
I have set selecting mode to full row selection, and I have no idea how to achieve my goal.
thanks a lot!
dataGridView1.ClearSelection();
Should work. Maybe you have code that auto selects rows which is triggered?