I have wrote code in vb.net to move to the previous row in datagridview when it reaches to first record and when I click again it generates an "index is out of range" error.
Dim i As Integer = DataGridView1.CurrentRow.Index - 1
Me.DataGridView1.CurrentCell = Me.DataGridView1.Rows(i).Cells(0)
Me.DataGridView1.Rows(i).Selected = True