Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 623
Spooks Avatar asked Oct 08 '10 15:10

Spooks


2 Answers

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.

like image 184
Dave Marley Avatar answered Oct 14 '22 03:10

Dave Marley


I had this same issue and nothing was working. The solution that worked for me was setting the 'Tabstop' property to False and calling the ClearSelection() method immediately after the data bind.

like image 38
DaneAnthony Avatar answered Oct 14 '22 03:10

DaneAnthony