Jump to content
Sign in to follow this  
tdwg83

Linked Combo Boxes

Recommended Posts

tdwg83

I am looking at using two combo boxes such that Combo1 is predefined and the listed returned in Combo2 is dependent on what is selected in Combo1. Does any one have any ideas on accomplishing. I can set defaults but can't get the list assigned to Combo2 to change.

Share this post


Link to post
Share on other sites
martin

I am looking at using two combo boxes such that Combo1 is predefined and the listed returned in Combo2 is dependent on what is selected in Combo1. Does any one have any ideas on accomplishing. I can set defaults but can't get the list assigned to Combo2 to change.

You can change the items by setting the list with the separator as the first character.

GuiCtrlSetDat($Combo2,"|a|b|c|d|e","a"); set new list of items, default to "a"


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
tdwg83

For example:

combobox 1 Lists:

1, 2, 3, 4, 5, 6

If You choose 1 second combo box lists

A,B,C,

If you choose 2 second combo box lists

D, E, F

etc....

Share this post


Link to post
Share on other sites
rasim

tdwg83

Hi! Try this:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>

Global $aLetters[7] = [6, "ABC", "DEF", "GHI", "JKL", "MNO", "PQR"]

$hGUI = GUICreate("Test GUI", 300, 200)

$hCombo1 = GUICtrlCreateCombo("", 50, 50, 200, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "1|2|3|4|5|6", 1)

$hCombo2 = GUICtrlCreateCombo("", 50, 100, 200, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "ABC|DEF|GHI|JKL|MNO|PQR", "ABC")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hCombo1
            $read = GUICtrlRead($hCombo1)
            GUICtrlSetData($hCombo2, $aLetters[$read], $aLetters[$read])
    EndSwitch
WEnd

GUIDelete()
$aLetters = 0

Share this post


Link to post
Share on other sites
tdwg83

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ComboConstants.au3>

Global $aLetters[7] = [6, "ABC", "DEF", "GHI", "JKL", "MNO", "PQR"]
Global $aLetter2[7] = [6, "abc", "def", "ghi", "jkl", "mno", "pqr"]

$hGUI = GUICreate("Test GUI", 300, 200)

$hCombo1 = GUICtrlCreateCombo("", 50, 50, 200, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "1|2|3|4|5|6", 1)

$hCombo2 = GUICtrlCreateCombo("", 50, 100, 200, 20, $CBS_DROPDOWNLIST)
GUICtrlSetData(-1, "")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $hCombo1
            $read = GUICtrlRead($hCombo1)
            If $read = 1 Then GUICtrlSetData($hCombo2, "ABC|DEF|GHI|JKL|MNO|PQR", "ABC")
            If $read = 2 Then GUICtrlSetData($hCombo2, "abc|def|ghi|jkl|mno|pqr", "def")
    EndSwitch
WEnd

GUIDelete()
$aLetters = 0

Modified version. Problem is combo box 2 doesn't clear just adds to the list

NEVERMIND

just had to start the lists with "|"

Thanks all

Edited by tdwg83

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.