Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My Form1 have above 10 Checkbox

how can I set the all checkbox to Unchecked


Dim xControl As Control
For Each xControl In me.Controls

   If TypeOf xControl Is TextBox Then
      xControl.ResetText()
   End If

   If TypeOf xControl Is CheckBox Then
      DirectCast(xControl , CheckBox).CheckState = CheckState.Unchecked
   End If

   If TypeOf xControl Is RadioButton Then
      DirectCast(xControl , RadioButton).Checked = False
   End If

   If TypeOf xControl Is ComboBox Then
      xControl.ResetText()
   End If

Next


That is my last Accept Solution
Posted
Updated 18-Jun-15 16:03pm
v4
Comments
Sergey Alexandrovich Kryukov 18-Jun-15 10:01am    
First of all, what do you mean by Form, exactly?
—SA

Something like this would do it
VB
For Each Control In Me.Controls
    If TypeOf (Control) Is CheckBox Then
        Dim work As CheckBox = Control
        work.Checked = False
    End If
Next
 
Share this answer
 
Comments
Member 11702607 18-Jun-15 21:36pm    
Dim xCheckBox As Control
For Each xCheckBox In Me.Controls
If TypeOf xCheckBox Is CheckBox Then
Dim work As CheckBox = CType(xCheckBox , CheckBox)
work.Checked = False
End If
Next
 
Share this answer
 
Dim xCheckBox As Control
For Each xCheckBox In Me.Controls
   If TypeOf xCheckBox Is CheckBox Then
      Dim work As CheckBox = CType(xCheckBox , CheckBox)
      work.Checked = False
   End If
Next
 
Share this answer
 
Dim xControl As Control
For Each xControl In me.Controls
 
   If TypeOf xControl Is TextBox Then
      xControl.ResetText()
   End If
 
   If TypeOf xControl Is CheckBox Then
      DirectCast(xControl , CheckBox).CheckState = CheckState.Unchecked
   End If
 
   If TypeOf xControl Is RadioButton Then
      DirectCast(xControl , RadioButton).Checked = False
   End If
 
   If TypeOf xControl Is ComboBox Then
      xControl.ResetText()
   End If
 
Next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900