Sir actually i want to know that when i press enter key then column value is incremented and i want that when i reach to column index 4 then a new row is created in datagridview and again this keydown event is executed and agin when i am in second row in gridview again a next row is created when column index is 4
so how to that .

through this code only i can move to next col when i press enter and i have made DataGridView1.AllowUserToAddRows = false

Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
If e.KeyCode = Keys.Enter Then
DataGridView1.AllowUserToAddRows = True

Dim ri As Integer = DataGridView1.CurrentCell.RowIndex
Dim ci As Integer = DataGridView1.CurrentCell.ColumnIndex
e.SuppressKeyPress = True
FindNextCell(DataGridView1, ri, ci + 1) 'checking from Next
End If
End Sub
Sub FindNextCell(ByVal dgv As DataGridView, ByVal rowindex As Integer, ByVal columnindex As Integer)
Dim found As Boolean = False
While dgv.RowCount > rowindex
While dgv.Columns.Count - 1 > columnindex
If Not (dgv.Rows(rowindex).Cells(columnindex)).ReadOnly Then
dgv.CurrentCell = dgv.Rows(rowindex).Cells(columnindex)
Exit Sub
Else
columnindex += 1
End If
End While

rowindex += 1
columnindex = 0

End If

End While
End Sub

This article has been dead for over six months. Start a new discussion instead.