Alle checkboxen leeg in groupbox

Status
Niet open voor verdere reacties.

Doofenshmirt

Gebruiker
Lid geworden
3 nov 2011
Berichten
222
Hoi,

Is het mogelijk om in 1 keer alle checkboxen in een groupbox leeg te maken ?

Doe het nu zo ,maar dat is erg lastig om dit veel te doen
Code:
CheckBox42.CheckState = 0
 
Dit werkt.


Code:
Private Sub ClearCheckBoxes(ByVal cc As Control)

        Dim ctl As Control ' Declare Variable for the Controls on the Form
        Dim cb As CheckBox ' Declare Variable for all the CheckBoxes

        For Each ctl In cc.Controls ' Loop through the Controls on the Form

          

            If TypeOf ctl Is CheckBox Then ' If the Control Found is a CheckBox

                cb = CType(ctl, CheckBox) ' Assign the Control to be a CheckBox

                cb.Checked = False ' Set the Checked Property of the Control to False

            End If

        Next

    End Sub
 
Je kan ook precies hetzelfde bereiken zonder te casten. Wat vind je van deze methode:

Code:
Private Sub ClearCheckBoxes(cc As Control)
For Each Ctrl As Control in cc.Controls 'Loop through each control in cc
If TypeOf Ctrl Is CheckBox Then cc.Checked = False 'If Ctrl is a checkbox, then set the Checked property to False
End Sub
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan