Tab key work as an Enter key in Datagridview

To make the Tab key work as Enter key, we have to inherit DataGridView controls and override two methods ProcessDataGridViewKey and ProcessDialogKey. In both the methods if the user has click Tab then we have to ProcessEnterKey of Datagridview.


Public Class NewDataGridView
Inherits DataGridView

Protected Overrides Function ProcessDataGridViewKey(ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean
If e.KeyCode = Keys.Tab Then
Me.ProcessEnterKey(e.KeyData)
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 = Keys.Tab Then
Me.ProcessEnterKey(keyData)
Return True
End If

Return MyBase.ProcessDialogKey(keyData)

End Function
End Class


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: