Enter key behaves like Tab in datagridview in vb.net

Most of the user use Enter key except Tab to move focus in the next controls because it is very faster to press Enter key instead of Tab key. But in .net the DataGridView works with Tab key to move focus in Next cell so we need to customize the datagridView and Overrides some function.

Add a new custom control in project and inherits it with System.Windows.Forms.DataGridView.

Code of Custom control:

Public Class CustomDataGridView
    Inherits DataGridView
    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        'Add your custom paint code here
    End Sub
    Protected Overrides Function ProcessDataGridViewKey(ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean
        If e.KeyCode = System.Windows.Forms.Keys.Enter Then
            Return True
        End If
        Return MyBase.ProcessDataGridViewKey(e)
    End Function
    Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If keyData = System.Windows.Forms.Keys.Enter Then
            Return True
        End If
        Return MyBase.ProcessDialogKey(keyData)
    End Function
End Class

After that Build the application then you will find that there in a new control in your toolbox named as your custom control name(‘CustomDataGridView’ in above example).

You can easily use this with drag and drop and in this datagridview enter key works as a tab key.