Navigate through datagridview using the enter key

Joined
Feb 13, 2009
Messages
12
Programming Experience
3-5
Hello,

I want to navigate through a datagridview using the enter key. This works find except when editing a new row.

Private Sub TblRoundsDataGridView_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles TblRoundsDataGridView.KeyDown
If e.KeyCode = Keys.Enter Then
Dim numCols As Integer = TblRoundsDataGridView.ColumnCount
Dim numRows As Integer = TblRoundsDataGridView.RowCount
Dim currCell As DataGridViewCell = TblRoundsDataGridView.CurrentCell
If currCell.ColumnIndex = numCols - 1 Then
If currCell.RowIndex < numRows - 1 Then
TblRoundsDataGridView.CurrentCell = TblRoundsDataGridView.Item(0, currCell.RowIndex + 1)
End If
Else
TblRoundsDataGridView.CurrentCell = TblRoundsDataGridView.Item(currCell.ColumnIndex + 1, currCell.RowIndex)
End If
e.Handled = True
End If

End Sub

I tried changing the editmode on the properties but no help?

Thanks for any help!
 
Last edited:

Latest posts

Back
Top