You could try to keep a list of
Textbox
es and focus the one with the next
TabIndex
when enter is hit.
Something like this might work for you;
Public Class Form1
Private ReadOnly textBoxes As IList(Of TextBox) = New List(Of TextBox)
Public Sub New()
InitializeComponent()
textBoxes.Add(TextBox1)
textBoxes.Add(TextBox2)
textBoxes.Add(TextBox3)
End Sub
Private Sub TextBox1_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) Handles TextBox1.PreviewKeyDown, TextBox2.PreviewKeyDown, TextBox3.PreviewKeyDown
If e.KeyCode = Keys.Enter Then
Dim source As TextBox = CType(sender, TextBox)
Dim nextTextbox As TextBox = textBoxes.Where(Function(tb) tb.TabIndex > source.TabIndex).OrderBy(Function(tb) tb.TabIndex).FirstOrDefault()
If nextTextbox Is Nothing Then nextTextbox = textBoxes.First()
nextTextbox.Focus()
End If
End Sub
End Class
Hope this helps,
Fredrik