Private Sub ClearData(ByVal parentCtr As Control, Optional ByVal ignoreControl As Object() = Nothing)
'Dim ignoreControl() As String = {ctr.name, ctr.name, ctr.name}
Dim ctr As Control
For Each ctr In parentCtr.Controls
If Array.IndexOf(ignoreControl, ctr.Name) >= 0 Then
If TypeOf ctr Is TextBox Then
CType(ctr, TextBox).Clear()
ElseIf TypeOf ctr Is ComboBox Then
DirectCast(ctr, ComboBox).SelectedIndex = -1
ElseIf TypeOf ctr Is ListBox Then
CType(ctr, ListBox).Items.Clear()
ElseIf TypeOf ctr Is DataGridView Then
CType(ctr, DataGridView).Rows.Clear()
ElseIf TypeOf ctr Is DateTimePicker Then
CType(ctr, DateTimePicker).Value = Date.Now
ElseIf TypeOf ctr Is DateTimePicker Then
CType(ctr, DateTimePicker).Value = Date.Now
ElseIf TypeOf ctr Is CheckBox Then
CType(ctr, CheckBox).Checked = False
ElseIf TypeOf ctr Is RadioButton Then
CType(ctr, RadioButton).Checked = False
ElseIf TypeOf ctr Is RadioButton Then
CType(ctr, RadioButton).Checked = False
End If
End If
ClearData(ctr, ignoreControl)
Next
End Sub
No comments:
Post a Comment