我有 25 个文本框控件。以下代码仅适用于 2 个文本框。所以对于 25 个文本框,代码会很长,我可以缩短代码吗?
Private Sub TextBox_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles IDTextBox.KeyDown, DateDateTimePicker.KeyDown, ItemCodeTextBox.KeyDown, BrandTextBox.KeyDown, ItemTextBox.KeyDown
If e.KeyCode = Keys.Enter And Me.IDTextBox.Focused Then
Me.DateDateTimePicker.Focus()
Else
If e.KeyCode = Keys.Down And Me.IDTextBox.Focused Then
Me.DateDateTimePicker.Focus()
Else
If e.KeyCode = Keys.Up And Me.DateDateTimePicker.Focused Then
Me.IDTextBox.Focus()
Else
If e.KeyCode = Keys.Enter And Me.DateDateTimePicker.Focused Then
Me.ItemCodeTextBox.Focus()
Else
If e.KeyCode = Keys.Down And Me.DateDateTimePicker.Focused Then
Me.ItemCodeTextBox.Focus()
Else
If e.KeyCode = Keys.Up And Me.ItemCodeTextBox.Focused Then
Me.DateDateTimePicker.Focus()
End If
End If
End If
End If
End If
End If
End Sub