DataGridView first column,first row, is selected on Load, I don't want this

Spooks picture Spooks · Oct 8, 2010 · Viewed 47k times · Source

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?

Answer

Dave Marley picture Dave Marley · Feb 24, 2011

I was having quite a bit of trouble with this myself. I have a user control with a DataGridView that is populated on application/form load. The selection of the first row seems to happen after databinding is complete and the grid is populated/rendered. The user control load event (and presumably, form load as well) fires prior to that - so calling gridView.ClearSelection() or nullifying gridView.CurrentCell in those load events has no net effect.

What finally worked for me was calling .ClearSelection() from the DataBindingComplete event of the DataGridView itself. This worked like a charm.