0
我遇到了这种情况下的问题(请参阅标题)。我在一个大面板中有6个子面板。我做了一个从主文本框继承的TextBox类。我正在尝试使用KeyPressed事件处理程序来处理Enter键。当用户按下输入键时,它将从子面板内的一个文本框移动到下一个子面板。到目前为止,我已经获得了输入关键事件处理程序,可以用于重点不在跳到下一个面板的面板。TextBox Enter Key - 主面板中的子面板
下面是我用来控制动作的子程序。 问题是我无法从一个子面板跳到另一个面板。任何帮助,将不胜感激!
Protected Shared Sub NextControl(ByVal tControl As Control, ByVal Direction As Boolean)
Dim pControl As Control = tControl.TopLevelControl
tControl = pControl.GetNextControl(tControl, Direction)
If Direction = False Then
Dim tParent As Control
While TypeOf tControl Is UserControl
tParent = tControl.Parent
tControl = pControl.GetNextControl(tControl, Direction)
If tControl.Parent Is tParent Then
Exit While
End If
End While
End If
If tBox_P00.ControlNesting > 0 Then
'Dim i As Integer
pControl = tControl.Parent
For i As Integer = 0 To tBox_P00.ControlNesting - 2
pControl = pControl.Parent
Next
End If
If Not tControl Is Nothing Then
Do Until (tControl.TabStop = True) AndAlso (tControl.Enabled = True) AndAlso (tControl.Visible = True) AndAlso (TypeOf tControl Is Tbx00)
tControl = pControl.GetNextControl(tControl, Direction)
'Last in the Panel
If tControl Is Nothing Then
tBox_P00.Select(0, tBox_P00.TextLength)
Beep()
Exit Sub
End If
Loop
tControl.Focus()
Else
tBox_P00.Select(0, tBox_P00.TextLength)
Beep()
End If
Exit Sub
End Sub
我没有看到问题。究竟出了什么问题? – 2012-07-30 18:13:03
该代码中循环的意图很不明确。只需调用GetNextControl()一次,不要做任何事情。 – 2012-07-30 18:22:26
子面板内至少有10个其他文本框。该循环将过滤掉未输入的输入。所以循环实际上看起来并试图找到下一个输入框。 – jsit208 2012-07-30 18:33:16