Jump to content

How do I populate a ComboBox based on Array.


sirjaymz
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...