Moist Posted November 19, 2018 Posted November 19, 2018 Hello guys, I tried looking for this but couldn't find anything. Let's say I have 2 dropdown lists in my GUI. In my first one I can select between A and B and the second one that is empty until I select something from the first one. If I select A from the first dropdown the values 1 and 2 appear to be selectable, if I select B from the first one, I get 3 and 4 to be selectable in the second dropdown. Can anyone explain me how to create these contextual dropdowns?
Moderators JLogan3o13 Posted November 19, 2018 Moderators Posted November 19, 2018 @Moist we normally operate on a "teach a man to fish" motto but I just happened to be working on something similar for my high-schooler. There are, of course, a dozen ways to skin the proverbial cat in AutoIt, but this should give you an idea. Please ask if you have any questions: #include <GUIConstantsEx.au3> Local $hGUI = GuiCreate("Test", 300, 200) $cmb1 = GUICtrlCreateCombo("Select a day", 10, 10, 100, 60) GUICtrlSetData($cmb1, "Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", "Select a day") $cmb2 = GUICtrlCreateCombo("Select a class", 120, 10, 100, 60) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cmb1 Switch GUICtrlRead($cmb1) Case "Tuesday" GUICtrlSetData($cmb2, "") GUICtrlSetData($cmb2, "Select a class|Math|Psych|Robotics", "Select a class") Case "Thursday" GUICtrlSetData($cmb2, "") GUICtrlSetData($cmb2, "Select a class|Trig|PE|Choir", "Select a class") EndSwitch EndSwitch WEnd Moist 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Moist Posted November 19, 2018 Author Posted November 19, 2018 4 minutes ago, JLogan3o13 said: @Moist we normally operate on a "teach a man to fish" motto but I just happened to be working on something similar for my high-schooler. There are, of course, a dozen ways to skin the proverbial cat in AutoIt, but this should give you an idea. Please ask if you have any questions: #include <GUIConstantsEx.au3> Local $hGUI = GuiCreate("Test", 300, 200) $cmb1 = GUICtrlCreateCombo("Select a day", 10, 10, 100, 60) GUICtrlSetData($cmb1, "Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", "Select a day") $cmb2 = GUICtrlCreateCombo("Select a class", 120, 10, 100, 60) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $cmb1 Switch GUICtrlRead($cmb1) Case "Tuesday" GUICtrlSetData($cmb2, "") GUICtrlSetData($cmb2, "Select a class|Math|Psych|Robotics", "Select a class") Case "Thursday" GUICtrlSetData($cmb2, "") GUICtrlSetData($cmb2, "Select a class|Trig|PE|Choir", "Select a class") EndSwitch EndSwitch WEnd Thank you so much.
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