//set forms KEYPREVIEW = TRUE
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
SendKeys "{TAB}"
End If
End Sub
But on VB.NET this won't work and not practical. Instead we can utilize the SelectNextControl of the current active control as shown below:
Private Sub nametxt_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles nametxt.KeyDown, gendertxt.KeyDown, agetxt.KeyDown
If e.KeyCode = Keys.Enter Then
Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
End If
End Sub
You can use the same event on all textboxes by adding the control.Keydown event from the Handles keyword of that event.
Private Sub nametxt_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles nametxt.KeyDown, gendertxt.KeyDown, agetxt.KeyDown //add any textbox here to use this event
That's all! your form's Enter key should now mimic the TAB key. Hope this help anyone.