vladedoty Posted September 3, 2009 Share Posted September 3, 2009 I have 2 radio buttons. I want my combobox to change data whenever the other radio button is checked for example say i have a combobox named $myCombo = GUICtrlCreateCombo("", 512, 120, 105, 25) and i have 2 radio buttons $radio1Option = GUICtrlCreateRadio("radio1", 32, 40, 113, 17) Global $radio2Option = GUICtrlCreateRadio("radio2", 160, 40, 113, 17) then i want the numbers 1,2,3,4 to appear in $myCombo when $radio1Option is checked and i want numbers 5,6,7,8 to appear if in $myCombo when $radio2Option is checked how would i do this??? Link to comment Share on other sites More sharing options...
notta Posted September 3, 2009 Share Posted September 3, 2009 #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $radio1, $radio2, $msg, $combo GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered $radio1 = GUICtrlCreateRadio("Radio 1", 10, 10, 120, 20) $radio2 = GUICtrlCreateRadio("Radio 2", 10, 40, 120, 20) $combo = GUICtrlCreateCombo("", 10, 70) GUICtrlSetState($radio2, $GUI_CHECKED) GUISetState() ; will display an dialog box with 1 checkbox ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED GUICtrlSetData($combo, "") ;clear control GUICtrlSetData($combo, "Radio1|Radio1|Radio1") Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED GUICtrlSetData($combo, "") ;clear control GUICtrlSetData($combo, "Radio2|Radio2|Radio2") EndSelect WEnd EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Manjish Posted September 9, 2009 Share Posted September 9, 2009 (edited) #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $radio1, $radio2, $msg, $combo GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered $radio1 = GUICtrlCreateRadio("Radio 1", 10, 10, 120, 20) $radio2 = GUICtrlCreateRadio("Radio 2", 10, 40, 120, 20) $combo = GUICtrlCreateCombo("", 10, 70) GUICtrlSetState($radio2, $GUI_CHECKED) GUISetState() ; will display an dialog box with 1 checkbox ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED GUICtrlSetData($combo, "") ;clear control GUICtrlSetData($combo, "Radio1|Radio1|Radio1") Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED GUICtrlSetData($combo, "") ;clear control GUICtrlSetData($combo, "Radio2|Radio2|Radio2") EndSelect WEnd EndFunc ;==>Example Just a simple flaw in above script.. Initially when radio2 is selected, the combobox has no data.. so just added a line at the beginning. #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $radio1, $radio2, $msg, $combo GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered $radio1 = GUICtrlCreateRadio("Radio 1", 10, 10, 120, 20) $radio2 = GUICtrlCreateRadio("Radio 2", 10, 40, 120, 20) $combo = GUICtrlCreateCombo("", 10, 70) GUICtrlSetState($radio2, $GUI_CHECKED) GUICtrlSetData($combo, "Radio2|Radio2|Radio2") GUISetState() ; will display an dialog box with 1 checkbox ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED GUICtrlSetData($combo, "") ;clear control GUICtrlSetData($combo, "Radio1|Radio1|Radio1") Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED GUICtrlSetData($combo, "") ;clear control GUICtrlSetData($combo, "Radio2|Radio2|Radio2") EndSelect WEnd EndFunc ;==>Example Edited September 9, 2009 by Manjish [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now