DGV - clear the default selection on first row?

retkehing

Well-known member
Joined
Feb 5, 2006
Messages
153
Programming Experience
Beginner
May i know how to clear the default selection on first row? I don't want anything to be selected when i execute the application, thank you.
 
set the CurrentCell property to value Nothing
 
I used the following to clear the default selection on row but when i executed the application, the first row of the DataGridView was still selected. I want nothing to be selected when the form is loaded. May i know how to do it? Thank you.

VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] DataGridView1.Rows.Count > 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]DataGridView1.CurrentRow.Selected = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE]
 
set the CurrentCell property to value Nothing
VB.NET:
DataGridView1.CurrentCell = Nothing
Both this and DGV.CurrentRow.Selected=False works for me. Are you filling/adding afterwards perhaps?
 

Latest posts

Back
Top