Jump to content

Recommended Posts

Posted

How can i read all items from a combobox?

i know how to read the selected item but not ALL items in the combobox.

im trying to create a list of profiles in this format 'profile1|profile2|profile3|profile4'. it will then be saved to a .ini file.

i read about _GUICtrlComboGetList, but thats in the beta stage?

Any help on this would be much appreciated.

Posted

Hello

in AutoIt 3.3.6.1 (this is an stable release) you can use _GUICtrlComboBox_GetList:

#include <ButtonConstants.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <array.au3>
#include <File.au3>
#Include <GuiComboBox.au3>

Const $sCSV = @ScriptDir & "\cboKFZ.TXT"
Const $sElect = "bitte auswählen"
Dim $aKFZ, $aSplit, $scboChr = ""
_FileReadToArray($sCSV, $aKFZ)
_ArraySort($aKFZ)
For $i = 1 To UBound($aKFZ) - 1
    ConsoleWrite($i & $aKFZ[$i] & @CRLF)
    $scboChr &= $aKFZ[$i]& "|"
Next
ConsoleWrite($scboChr & @CRLF)

$hGui = GUICreate("Combobox aus TXT-Datei", 250, 85, 302, 218)
$idCboKFZ = GUICtrlCreateCombo($sElect, 8, 8, 200, 25)
GUICtrlSetTip(-1,"Automarke auswählen")
GUICtrlSetData(-1, $scboChr)
$idBtnINFO = GUICtrlCreateButton("&Info", 5, 40)
GUICtrlSetState(-1,$Gui_DISABLE)
GUICtrlSetTip(-1,"MsgBox zeigen")
$idBtnAll = GUICtrlCreateButton("&alle auslesen", 50, 40)   ;read all
GUICtrlSetTip(-1,"Programm beenden")
$idBtnExit = GUICtrlCreateButton("Be&enden", 175, 40)
GUICtrlSetTip(-1,"Programm beenden")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $idBtnExit
            Exit
        Case $idCboKFZ
            if GUICtrlRead($idCboKFZ) = $sElect Then
                GUICtrlSetState($idBtnINFO,$Gui_DISABLE)
            Else
                GUICtrlSetState($idBtnINFO,$Gui_ENABLE)
            EndIf
        Case $idBtnINFO
            MsgBox(0,"Info",GUICtrlRead($idCboKFZ))
        case $idBtnAll
            $sKFZ = _GUICtrlComboBox_GetList($idCboKFZ)
            MsgBox(0,"KFZ",$sKFZ)
    EndSwitch
WEnd

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
×
×
  • Create New...