所以,
我在 tabcontrol 页面上有一个文本框,当有人跳出文本框时,它应该移动到下一个选项卡。在我将表单从 UserControl 切换到实际表单之前,这非常有效。此更改并未更改实际代码。
所以现在,我已经尝试了一切。我将文本框设置为 AcceptTab = True,并且我有 KeyPreview = False(因为如果表单在文本框之前抓取事件,我假设它会搞砸)。
这是我的文本框代码:
Private Sub txtMsgDTG_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles txtMsgDTG.KeyDown
'check for tabbed out
If e.KeyCode = Keys.Tab Then
'If the user tabs into this field after filling out the necessary fields ...
If txtMsgDTG.Text = String.Empty Then
'If the user left the field BLANK ...
'Move to next page:
TabControl1.TabPages(0).Enabled = True
TabControl1.TabPages(1).Enabled = True
TabControl1.TabPages(2).Enabled = False
TabControl1.TabPages(3).Enabled = False
TabControl1.TabPages(4).Enabled = False
TabControl1.SelectedIndex = 1
Else
'If the user did NOT leave the field blank ...
'validate message DTG
Dim dtgCheck As String
dtgCheck = ValidateDTG(txtMsgDTG.Text)
If dtgCheck <> "valid" Then
MsgBox(dtgCheck)
Else
'Move to next page:
TabControl1.TabPages(0).Enabled = True
TabControl1.TabPages(1).Enabled = True
TabControl1.TabPages(2).Enabled = False
TabControl1.TabPages(3).Enabled = False
TabControl1.TabPages(4).Enabled = False
TabControl1.SelectedIndex = 1
End If
End If
End If
End Sub
有什么想法吗?