Jump to content

Linked Combo Boxes


 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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

#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
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...