Sign in to follow this  
Followers 0
BrettF

Combobox And Arrays...

4 posts in this topic

#1 ·  Posted (edited)

Hi, Is it possible to set the data in a combo box from an array? I have tried a few things but nothing works. Could someone please help??

What i've Tried:

#include <GUIConstants.au3>
#Include <GuiCombo.au3>
Global $States[7] = ["NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA"]
#Region ### START Koda GUI section ### Form=d:\my documents\My Stuff\BOM AUST\Mainscrn.kxf
$Form1 = GUICreate("Exod-Ar: Australian Beauru of Metorology Weather Radar", 616, 514, 201, 118)
$Pic1 = GUICtrlCreatePic("d:\my documents\My Pictures\australia-radar-map.bmp", 8, 8, 600, 420, BitOR($SS_NOTIFY, $WS_GROUP))
$Group1 = GUICtrlCreateGroup("Step 1:", 8, 432, 193, 73)
$Label1 = GUICtrlCreateLabel("Select a State in Australia:", 16, 448, 179, 17)
$State = GUICtrlCreateCombo($States[0], 16, 472, 177, 25)
$Group2 = GUICtrlCreateGroup("Step 2:", 208, 432, 193, 73)
$Label2 = GUICtrlCreateLabel("Select a radar Location:", 216, 448, 179, 17)
$RadarLoc = GUICtrlCreateCombo("RadarLoc", 216, 472, 177, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Step 3:", 408, 432, 193, 73)
$Label3 = GUICtrlCreateLabel("Click OK!", 414, 451, 179, 17)
$ShowDar = GUICtrlCreateButton("OK!", 472, 472, 83, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

_GUICtrlComboAddString($State, $States[1])
_GUICtrlComboAddString($State, $States[2])
_GUICtrlComboAddString($State, $States[3])
_GUICtrlComboAddString($State, $States[4])
_GUICtrlComboAddString($State, $States[5])
_GUICtrlComboAddString($State, $States[6])

The While loop isnt necessary as it's well, empty :whistle:

I really whant to know if the data in $state can be set in one line??

Thanks

EDIT: I have to set around 15 things in the combo, and i just want to minimise the code length :)

Edited by bert

Share this post


Link to post
Share on other sites



Try this out

I changed the way the array is created (according to the helpfile for _arrayCreate)

I also added the While ... WEnd loop to it, along with the check for closing the window

just because it was easier to test that way.

#include <GUIConstants.au3>
#Include <GuiCombo.au3>
#Include <Array.au3>

Global $States
$states = _ArrayCreate("NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA")
#Region ### START Koda GUI section ### Form=d:\my documents\My Stuff\BOM AUST\Mainscrn.kxf
$Form1 = GUICreate("Exod-Ar: Australian Beauru of Metorology Weather Radar", 616, 514, 201, 118)
$Pic1 = GUICtrlCreatePic("d:\my documents\My Pictures\australia-radar-map.bmp", 8, 8, 600, 420, BitOR($SS_NOTIFY, $WS_GROUP))
$Group1 = GUICtrlCreateGroup("Step 1:", 8, 432, 193, 73)
$Label1 = GUICtrlCreateLabel("Select a State in Australia:", 16, 448, 179, 17)
$State = GUICtrlCreateCombo($States[0], 16, 472, 177, 25)
$Group2 = GUICtrlCreateGroup("Step 2:", 208, 432, 193, 73)
$Label2 = GUICtrlCreateLabel("Select a radar Location:", 216, 448, 179, 17)
$RadarLoc = GUICtrlCreateCombo("RadarLoc", 216, 472, 177, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Step 3:", 408, 432, 193, 73)
$Label3 = GUICtrlCreateLabel("Click OK!", 414, 451, 179, 17)
$ShowDar = GUICtrlCreateButton("OK!", 472, 472, 83, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

For $i = 1 to 6 step 1
_GUICtrlComboAddString($State, $States[$i])
Next

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
Wend

Share this post


Link to post
Share on other sites

I really don't see where you did anything but throw a GUI together in Koda to address the situation you are wanting to rectify.

#include <GUIConstants.au3>
#Include <GuiCombo.au3>
Global $States[7] = ["NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA"]
#Region ### START Koda GUI section ### Form=d:\my documents\My Stuff\BOM AUST\Mainscrn.kxf
$Form1 = GUICreate("Exod-Ar: Australian Beauru of Metorology Weather Radar", 616, 514, 201, 118)
$Pic1 = GUICtrlCreatePic("d:\my documents\My Pictures\australia-radar-map.bmp", 8, 8, 600, 420, BitOR($SS_NOTIFY, $WS_GROUP))
$Group1 = GUICtrlCreateGroup("Step 1:", 8, 432, 193, 73)
$Label1 = GUICtrlCreateLabel("Select a State in Australia:", 16, 448, 179, 17)
$State = GUICtrlCreateCombo($States[0], 16, 472, 177, 25)
$Group2 = GUICtrlCreateGroup("Step 2:", 208, 432, 193, 73)
$Label2 = GUICtrlCreateLabel("Select a radar Location:", 216, 448, 179, 17)
$RadarLoc = GUICtrlCreateCombo("RadarLoc", 216, 472, 177, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Step 3:", 408, 432, 193, 73)
$Label3 = GUICtrlCreateLabel("Click OK!", 414, 451, 179, 17)
$ShowDar = GUICtrlCreateButton("OK!", 472, 472, 83, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)

_GUICtrlComboAddArray($State, $States)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While GUIGetMsg() <> -3
WEnd

Func _GUICtrlComboAddArray($nCID, $aArray, $iBase = 0)
    Local $sHold
    For $iCC = $iBase To UBound($aArray) - 1
        $sHold &= $aArray[$iCC] & '|'
    Next
    Return GUICtrlSetData($nCID, $sHold)
EndFunc


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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  
Followers 0