barryb Posted September 21, 2011 Share Posted September 21, 2011 Hi All, been away from AutoIt for a while and I'm stuck trying to populate my dropdown combo box with data gathered in to an Array The code below parses all my removable media, but I need to be able to use this to populate my combo box but couldn't find any examples in the help, I'm sure this is something really simple. but I can't get my head around how to do this, I'm sure it will be some type of For loop to add in each found drive in to the combo Box but I can't figure it out. A friendly push in the right direction would be great. Thanks, Barry Local $var = DriveGetDrive("REMOVABLE") For $usb = 1 to $var[0] MsgBox (0,"Drive", $var[$usb]) next Link to comment Share on other sites More sharing options...
shornw Posted September 21, 2011 Share Posted September 21, 2011 Using Ubound() in a loop sounds like what you;re looking for [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font] Link to comment Share on other sites More sharing options...
barryb Posted September 21, 2011 Author Share Posted September 21, 2011 Thanks Shornw I will give that a try when I get a chance! Cheers, Barry Link to comment Share on other sites More sharing options...
shornw Posted September 21, 2011 Share Posted September 21, 2011 Try this, it worked for me, although I substituted "NETWORK" for "REMOVABLE" for my test purposes. #include <GUIConstantsEx.au3> Local $var = DriveGetDrive("NETWORK") GUICreate("Test", 230, 60) $com = GUICtrlCreateCombo( "", 10, 10) ;Create combe For $d = 1 To UBound($var) -1 ; Set data GUICtrlSetData( -1, $var[$d] & "|") Next GuiSetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd barryb 1 [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font] Link to comment Share on other sites More sharing options...
barryb Posted September 21, 2011 Author Share Posted September 21, 2011 Hi ShornW, Turns out I was a complete nooblet and was over thinking this! I looked at what someone else had done for a similar issue and it was a lot easier than I thought I just needed to use array to string However this may or may not work for me so I will look at the code you created as well, as you can tell my test code is cut from the help lol Func Example() Local $msg, $sDriveList Local $var = DriveGetDrive("REMOVABLE") $sDriveList = _ArrayToString($var, "|", 1) ; drives string GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered GUICtrlCreateCombo("Select Drive", 10, 10) ; create first item GUICtrlSetData(-1, $sDriveList, "") ; add other item snd set a new default GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>Example Link to comment Share on other sites More sharing options...
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