Programmatically change selection on DatagridView (.NET)

Maybe something like this:

    If DataGridView1.RowCount > 0 Then

        Dim MyDesiredIndex As Integer = 0

        If DataGridView1.CurrentRow.Index < DataGridView1.RowCount - 1 Then
            MyDesiredIndex = DataGridView1.CurrentRow.Index + 1
        End If

        DataGridView1.ClearSelection()            
        DataGridView1.CurrentCell = DataGridView1.Rows(MyDesiredIndex).Cells(0)
        DataGridView1.Rows(MyDesiredIndex).Selected = True

    End If

Note 1: maybe these two lines are not necessary. I haven´t proved it

        DataGridView1.ClearSelection()            
        DataGridView1.CurrentCell = DataGridView1.Rows(MyDesiredIndex).Cells(0)

Note 2: note that if we are in the last row, it goes to first


You need to set the particular row's Selected property to true. I think the VB would be something like this:

someDGV.Rows(index).Selected = True