views:

61

answers:

2

So basically the very first column in the first row is always selected, I can't figure out a way to have it so the gridview has no selected cells. Any help?

A: 

Try

gridView.ClearSelection();

If you want the selected cells cleared when a form loads, try putting that in the form's Load event handler.

kevev22
A: 

Set the DGV's CurrentCell property to null after data binding the DGV:

dataGridView1.CurrentCell = null; 

Note that doing this won't prevent DGV events associated with row and cell selection from firing; you'll have to add selected row or cell count checks on RowEnter events, something like this:

private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e) {
    if (dataGridView1.SelectedRows.Count == 1) {
        // Do stuff since a row is actually selected ...
    }
}
Jay Riggs