Jump to content

Recommended Posts

Posted

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
Posted

@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

 

"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!

Posted
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. :)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...