0

Dear Experts

Is there an easy way to move into datagridview columns with ENTER key instead of TAB key.

In other words: how to move in next column with enter key?

Please help

2
Contributors
1
Reply
8
Views
7 Years
Discussion Span
Last Post by __avd
0

>how to move in next column with enter key?

Handle the KeyDown event.

Private Sub DataGridView1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
        If e.KeyCode = Keys.Enter Then
            Dim numCols As Integer = DataGridView1.ColumnCount
            Dim numRows As Integer = DataGridView1.RowCount
            Dim currCell As DataGridViewCell = DataGridView1.CurrentCell
            If currCell.ColumnIndex = numCols - 1 Then
                If currCell.RowIndex < numRows - 1 Then
                    DataGridView1.CurrentCell = DataGridView1.Item(0, currCell.RowIndex + 1)
                End If
            Else
                DataGridView1.CurrentCell = DataGridView1.Item(currCell.ColumnIndex + 1, currCell.RowIndex)
            End If
            e.Handled = True
        End If
    End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.