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?
dataGridView1.ClearSelection();
Should work. Maybe you have code that auto selects rows which is triggered?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With