Im Versuch, all das Feld im Textfeld zu löschen und alle Kontrollkästchen deaktivieren, wenn das Formular auf LastWie für jedes in Multiple Control zu verwenden?
meine Checkbox sind innerhalb Table All, aber ich habe eine Menge von Table
Aktuell im, mit dieser Methode, aber es ist zu viele doppelten Code
Private Sub ResetPage()
Dim ctrl As Control
For Each ctrl In tlp_userInfo.Controls
If TypeOf ctrl Is TextBox Then
ctrl.Text = Nothing
End If
If TypeOf ctrl Is ComboBox Then
ctrl.Text = Nothing
End If
Next
For Each ctrl In tlp_chkb1.Controls
If TypeOf ctrl Is CheckBox Then
DirectCast(ctrl, CheckBox).Checked = False
End If
Next
For Each ctrl In tlp_chkb2.Controls
If TypeOf ctrl Is CheckBox Then
DirectCast(ctrl, CheckBox).Checked = False
End If
Next
For Each ctrl In tlp_chkb3.Controls
If TypeOf ctrl Is CheckBox Then
DirectCast(ctrl, CheckBox).Checked = False
End If
Next
End Sub
ist, dass jede andere Art und Weise alle das Kontrollkästchen in diffrent Table zu deaktivieren?
Edited:
Schließlich ich es bekommen getan, aber ich glaube nicht, dass dies eine gute Idee ist, wenn das Formular so viel Schicht aufweist.
For Each ctrl_layer1 As Control In Me.Controls
If TypeOf ctrl_layer1 Is TableLayoutPanel Then
For Each ctrl_layer2 As Control In ctrl_layer1.Controls
If TypeOf ctrl_layer2 Is TableLayoutPanel Then
For Each ctrl_layer3 As Control In ctrl_layer2.Controls
If TypeOf ctrl_layer3 Is TableLayoutPanel Then
For Each ctrl_layer4 In ctrl_layer3.Controls
If TypeOf ctrl_layer4 Is TextBox Then
ctrl_layer4.Text = ""
ElseIf TypeOf ctrl_layer4 Is ComboBox Then
ctrl_layer4.Text = ""
ElseIf TypeOf ctrl_layer4 Is TabControl Then
For Each ctrl_layer5 As Control In ctrl_layer4.controls
If TypeOf ctrl_layer5 Is TabPage Then
For Each ctrl_layer6 In ctrl_layer5.Controls
If TypeOf ctrl_layer6 Is TableLayoutPanel Then
For Each ctrl_layer7 In ctrl_layer6.controls
If TypeOf ctrl_layer7 Is TableLayoutPanel Then
For Each ctrl_layer8 In ctrl_layer7.controls
If TypeOf ctrl_layer8 Is CheckBox Then
DirectCast(ctrl_layer8, CheckBox).Checked = False
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
End If
Next
Sie sollten Looping starten von 'ctrl_layer3' nur, was ist der Punkt der Schleife 'ctrl_layer1' und' ctrl_layer2'? –