Link to home
Start Free TrialLog in
Avatar of alfardan
alfardanFlag for United Arab Emirates

asked on

DataGridView - Row Selection

Hi

I have a daragrid in a windows application, and when it loads it selects its first row by default, I don't want that, how do I let this datagrid selects no row when it loads?
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

after bounding data just call

dataGridView.ClearSelection();

(calling .ClearSelection() from the DataBindingComplete event of the DataGridView itself.)
Avatar of alfardan

ASKER

I'm not binding data to the grid, I'm adding rows through a for loop
Not sure if this will work, but try setting the currentcell to nothing at the end of the form load event, e.g
Me.DataGridView1.CurrentCell = Nothing

Open in new window

Didn't work, still selects the first row by default
Then
Me.DataGridView1.ClearSelection()

Open in new window

and / or setting the tab index for the datagridview to greater than 0 should work
Didn't work either

Ok, how do I make the row selection coloring to be of a specific color that I determine  instead of the default BLUE one?
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial