Sign in to follow this  
Followers 0
NSearch

Checkbox Questions

5 posts in this topic

I have two check boxes, I would like to be able to select only one. When one is selected, I would like the other to unselect. Would someone please help.

Thanks.

Share this post


Link to post
Share on other sites



I have two check boxes, I would like to be able to select only one. When one is selected, I would like the other to unselect. Would someone please help.

Thanks.

Lets say you've got checkbox[1] as your first checkbox and checkbox[2] as your second checkbox. Now you have to do

While 2
     $msg = GUIGetMsg()
     Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $checkbox[1]
                         GUICtrlSetState($checkbox[2],$GUI_UNCHECK)
        Case $msg = $checkbox[2]
                         GUICtrlSetState($checkbox[1],$GUI_UNCHECK)
     EndSelect
 WEnd

Think that would work


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

#include <guiconstants.au3>

$m = GUICreate('test')

$nonms = GUICtrlCreateCheckbox('test checkbox', 10, 10, 120)
$nonms2 = GUICtrlCreateCheckbox('test checkbox 2', 10, 30, 120)


GUISetState()

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         Exit
      Case $msg = $nonms
         If BitAND(GUICtrlRead($nonms), $GUI_CHECKED) Then GUICtrlSetState($nonms2,$GUI_UNCHECKED)
      Case $msg = $nonms2
         If BitAND(GUICtrlRead($nonms2), $GUI_CHECKED) Then GUICtrlSetState($nonms,$GUI_UNCHECKED)
   EndSelect
WEnd


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

You should really use the radio control (to be consistent with standard user-interface design). Plus, you just need to replace GuiCtrlCreateCheckbox with GuiCtrlCreateRadio without adding additional code :o

#include <GUIConstants.au3>
GUICreate("Example")

$radio1 = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
    GUICtrlSetState ($radio1, $GUI_CHECKED)
$radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)

GUISetState ()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
Wend

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Thank you all very much for your input.

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  
Followers 0