Jump to content

popup combo box after select in other combo box


Jilo
 Share

Recommended Posts

Hello,

i am very new to this autoit. I am trying to create a combobox that pop up after i choose a option in other combo box and get a result 

something like if i choose TYPE A. The combobox will show only TYPE A options and after i selected options then it display in a result box.

here is my code so far.

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ComboConstants.au3>

 


    Local $Type, $Select, $Result, $msg
    GUICreate("My GUI combo")

    $Type = GUICtrlCreateCombo("Choose TYPE", 10, 10,150,20,$CBS_DROPDOWNLIST);
    GUICtrlSetData(-1, "|TYPE A|TYPE B|TYPE C")

      $Select = GUICtrlCreateCombo("",10,35,200,20,$CBS_DROPDOWNLIST)

   $Result = GUICtrlCreateInput("",200,10,50,20)

    GUISetState()


    While 1
        $msg = GUIGetMsg()

         If $msg = $GUI_EVENT_CLOSE Then ExitLoop

         If GUICtrlRead($Type) =  "Choose TYPE"  Then
            GUICtrlSetState($Select, $GUI_HIDE)
         ElseIf GUICtrlRead($Type) =  "TYPE A"  Then
            GUICtrlSetData($Select,"A-01|A-02|A-03|A-04|A-05|A-06|A-07|A-08|A-09|A-10")
         ElseIf GUICtrlRead($Type) =  "TYPE B" Then
            GUICtrlSetData($Select,"B-01|B-02|B-03|B-04|B-05|B-06|B-07|B-08|B-09|B-10")
         EndIf

         $Result = GUICtrlRead($Select)


    WEnd

Sorry for my bad English and bad script. I am not good in both English and Autoit, :(

Please help

 

Link to comment
Share on other sites

You can do this:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ComboConstants.au3>
#include <GuiComboBox.au3>



Local $Type, $Select, $Result, $msg
GUICreate("My GUI combo")

$Type = GUICtrlCreateCombo("Choose TYPE", 10, 10, 150, 20, $CBS_DROPDOWNLIST);
GUICtrlSetData(-1, "|TYPE A|TYPE B|TYPE C")

$Select = GUICtrlCreateCombo("", 10, 35, 200, 20, $CBS_DROPDOWNLIST)
$Result = GUICtrlCreateInput("", 200, 10, 50, 20)

GUISetState()
Local Const $aData[] = ["A-01|A-02|A-03|A-04|A-05|A-06|A-07|A-08|A-09|A-10", "B-01|B-02|B-03|B-04|B-05|B-06|B-07|B-08|B-09|B-10", "C-01|C-02|C-03"]
Local $idMsg = 0
While 1
    $idMsg = GUIGetMsg()
    Select
        Case $idMsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $idMsg = $Type
            GUICtrlSetData($Select, "")
            GUICtrlSetData($Select, $aData[_GUICtrlComboBox_GetCurSel($Type)])
        Case $idMsg = $Select
            GUICtrlSetData($Result,GUICtrlRead($Select))
    EndSelect


WEnd
GUIDelete()

Saludos

Link to comment
Share on other sites

Thank you so much Danyfirex. It work now :)  i had been try to do this for 3 days now XD. At this moment.... i still confuse and not understand your code. i think i will need to practice and read more on coding.

Edited by Jilo
Link to comment
Share on other sites

AutoIt has a Form Designer (while SciTE is foreground, press alt+m or go to Tools>Koda(FormDesigner)).

To set combo boxes, click on the combo box you want to set and on the Object Inspector window (bottom left window):

The Text field should contain your default value.

The Items field should contain any other values you wish to include. You can set the items field easily by first clicking on the current value of the Items field and then clicking on the button with the "..." in it. It will open up a box to put your choices. Each choice should be on its own line.

(By default, Items field will say "(TStrings)" )

 

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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