vb.net Code:
Private Sub SelectNextControlOnEnterKey(ByVal sender As Object, _
ByVal e As KeyPressEventArgs) Handles TextBox1.KeyPress, _
TextBox2.KeyPress, _
TextBox3.KeyPress
If e.KeyChar = ControlChars.Cr Then
Me.SelectNextControl(DirectCast(sender, _
Control), _
True, _
True, _
True, _
True)
e.Handled = True
End If
End Sub
You could use the KeyDown event and set e.SuppressKeyPress to True but the advantage of using the KeyPress event is that if you keep the Enter key depressed focus will continue to move from control to control, which is the same behaviour as the Tab key.