BrettF Posted February 10, 2007 Posted February 10, 2007 (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 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 February 10, 2007 by bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
tAKTelapis Posted February 10, 2007 Posted February 10, 2007 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
Moderators SmOke_N Posted February 10, 2007 Moderators Posted February 10, 2007 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 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.
BrettF Posted February 10, 2007 Author Posted February 10, 2007 That was my most recent attempt Thanks SmokeN Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now