Im trying to clear all the field in textbox and uncheck all checkbox when the form on load
All my checkbox are inside TableLayoutPanel, but i have alot of TableLayoutPanel
Currently im using this method, but there is too many duplicate 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
is that any other way to uncheck all the checkbox in diffrent TableLayoutPanel?
Aucun commentaire:
Enregistrer un commentaire