Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / SQL

DataGridView: Make Enter Key Move to Next Column

1.77/5 (5 votes)
7 Dec 2011CPOL 80.2K  
DataGridView: Make Enter Key Move to Next Column
To make a datagridview move to the next column when you press the enter key.

Using Enter Key to Move to nextCell...

VB
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
    SendKeys.Send("{up}")
    SendKeys.Send("{right}")
End Sub
Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
    If e.KeyCode = Keys.Enter Then
        SendKeys.Send("{up}")
        SendKeys.Send("{right}")
    End If

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)