1

how can i select full and first row of datagridview in vb.net on form_Load

Web Worm
  • 2,080
  • 12
  • 40
  • 65

3 Answers3

11

I´m not sure if all these lines are strictely necessary, but this should work:

If MyDataGridView.RowCount > 0 Then
    MyDataGridView.ClearSelection()
    MyDataGridView.CurrentCell = Me.Rows(0).Cells(0)
    MyDataGridView.Rows(0).Selected = True
End If

Ah, if you want to select the full row, the DataGridView Selection Mode property must be FullRowSelect

Javier
  • 4,051
  • 2
  • 22
  • 20
1
DataGrid1.Rows(0).Selected = True
KHALID
  • 87
  • 7
0
DataGridView.SelectedIndex = 0
Eric
  • 7,930
  • 17
  • 96
  • 128