Jump to content
Sign in to follow this  
sirjaymz

How do I populate a ComboBox based on Array.

Recommended Posts

sirjaymz

Here is a snippet of code I am trying to use in a form. I call this function from a SetOnevent for my combobox.

CODE

Func ComboRobotCmdSetChange()

Local $search

Local $done = 0

Local $a_RobotCmdSetFile

Dim $a_RobotCmdSetArray[1]

; Shows the filenames of all Robotic control files in the current directory

$search = FileFindFirstFile("Control -*.au3")

; Check if the search was successful

If $search = -1 Then

MsgBox(0, "Error", "No Robot Control Files found.")

Else

While $done = 0

$a_RobotCmdSetFile = FileFindNextFile($search)

If @error Then

$done = 1

Else

_ArrayAdd( $a_RobotCmdSetArray, $a_RobotCmdSetFile)

EndIf

WEnd

GUICtrlSetData ($ComboRobot1CmdSet, $a_RobotCmdSetArray[0]&'|'&$a_RobotCmdSetArray[1], "None")

; Close the search handle

FileClose($search)

EndIf

EndFunc ; ComboRobotCmdSetChange

I do have a file name Control - Composer.au3, however, it never get's displayed in the combobox.

what am i missing, or am i just not getting it?

Share this post


Link to post
Share on other sites
Zedna

Try something like this:

Func ComboRobotCmdSetChange()
    ; Shows the filenames of all Robotic control files in the current directory
    $search = FileFindFirstFile("Control -*.au3")
    ; Check if the search was successful
    If $search = -1 Then
        MsgBox(0, "Error", "No Robot Control Files found.")
    Else
        $data = ''
        While 1
            $a_RobotCmdSetFile = FileFindNextFile($search)
            If @error Then ExitLoop
            $data &= $a_RobotCmdSetFile & '|'
        WEnd
        $data = StringTrimRight($data,1)
;~      ConsoleWrite($data & @CRLF)
        GUICtrlSetData($ComboRobot1CmdSet, $data, "None")
        ; Close the search handle
        FileClose($search)
    EndIf
EndFunc   ;==>ComboRobotCmdSetChange

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.