Jump to content
Sign in to follow this  
probedrone

"One box to check them all..."

Recommended Posts

probedrone

Hey, anyone know of a way to create a list of checkboxes in GUI where one of them, if checked, will select all the other ones?

Share this post


Link to post
Share on other sites
Helge

Something like this ?

#include <GUIConstants.au3>

GUICreate("", 300, 180)
GUICtrlCreateLabel("Describe Helge...", 10, 10, 280, 20, $SS_CENTER)
$check1 = GUICtrlCreateCheckbox("Cool", 10, 35, 280, 20, $BS_PUSHLIKE)
$check2 = GUICtrlCreateCheckbox("Retarded", 10, 60, 280, 20, $BS_PUSHLIKE)
$check3 = GUICtrlCreateCheckbox("Strange", 10, 85, 280, 20, $BS_PUSHLIKE)
$check4 = GUICtrlCreateCheckbox("Genius", 10, 110, 280, 20, $BS_PUSHLIKE)
$checkall = GUICtrlCreateCheckbox("All", 10, 150, 280, 20, $BS_PUSHLIKE)
GUISetState()

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then Exit

    If $msg = $checkall Then
        If BitAND(GUICtrlRead($checkall), $GUI_CHECKED) Then
            For $i =  $check1 To $check4
                GUICtrlSetState($i, $GUI_CHECKED)
            Next
        Else
            For $i =  $check1 To $check4
                GUICtrlSetState($i, $GUI_UNCHECKED)
            Next
        EndIf
    EndIf
WEnd

Share this post


Link to post
Share on other sites
probedrone

Question 2:

Say I have a subgroup of checkboxes. If I check the "select all" box, I want ALL the boxes to be checked, but when i check the "select subgroup" box, I only want those boxes in the subgroup checked. Any way to do this?

Edit: nvm i got it

Edited by probedrone

Share this post


Link to post
Share on other sites
Bert

Its the same thing, except the checkall box would only point to the subs you want. If you look in the script where it has the variable $checkall, you will see in the while loop what happens when it is checked. just change that to point to the checkboxes you want.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.