Jump to content
Sign in to follow this  
PerryRaptor

Add another ComboBox

Recommended Posts

I want to add another ComboBox to the Gui and re-use the function at the end of the script. I've tried adding another IF > Then for the second box, ended with a While/Wend error.

#include <GUIConstants.au3>
#include <File.au3>
$in_filename = "test.csv"
Dim $lines,$Display, $NumCols
_FileReadToArray($in_filename, $lines)
$Columns = StringSplit($lines[1], ",")
$NumCols=$Columns[0]
Dim $array[ $lines[0] ][ $Columns[0] ]
For $i = 1 To $lines[0]
    $Columns = StringSplit($lines[$i], ",")
    If $Columns[0] = 1 Then Continueloop
    For $j = 1 To $Columns[0]
        $array[$i-1][$j-1] = $Columns[$j]
    Next
Next
$Rows=$Lines[0]-1
For $i = 1 To $lines[0]-1
;---------------------------------------------------------------------
;Display Entire CSV File converted to an Array
;---------------------------------------------------------------------
    For $j = 1 To $NumCols
  $Display  = $Display&"array["&String($i-1)&"]["&String($j-1)&"]="&chr(9)&$array[$i-1][$j-1]&@CRLF
    Next
Next
;MsgBox(4096, "Here is your CSV File",$Display)

;---------------------------------------------------------------------
;Get the contents of Column A for every row 
;  Add a "|" at the end of each item
;---------------------------------------------------------------------
Dim $ColumnA, $AllColumnA, $H_cmb, $H_ComboBox, $H_Return
$SS_left = 0x1000
$M = 0
While $m <= $Rows -1
    $ColumnA=$Array[$m][0] & "|"
    $m = $m + 1
    $AllColumnA=$AllColumnA & $ColumnA
Wend
;---------------------------------------------------------------------
;Display the contents of Column A in a ComboBox
;  Display Column B contents in an InputBox
;  Display Column C contents in a GuiCtrlCreateLabel 
;---------------------------------------------------------------------
GUICreate("ComboBox view for contents of Column A for all Rows",550,100,-1,-1)
$h_cmb = GUICtrlCreateCombo("", 10,10,150)
GUICtrlSetData(-1,$AllColumnA)
;$h_cmb = GUICtrlCreateCombo("", 10,40,150)
;GUICtrlSetData(-1,$AllColumnA)
GUISetState ()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $h_cmb Then
        GuiCtrlCreateLabel(_GUICtrlComboBoxIndex($h_cmb),165,13,30)
        GuiCtrlCreateLabel($Array[$H_Return][2],195,13,300,30)
;   If $msg = $h_cmb Then
;       GuiCtrlCreateLabel(_GUICtrlComboBoxIndex($h_cmb), 165,43,30)
;       GuiCtrlCreateLabel($Array[$H_Return][2],195,43,300,30)
    EndIf
Wend
;---------------------------------------------------------------------
;Function used with "Display the contents of Column A in a ComboBox"
;  Returns the row (aka Line Number) for the item selected
;  Returns the data contained in Columns B and C
;---------------------------------------------------------------------
Func _GUICtrlComboBoxIndex($H_ComboBox)
    Dim $CB_GETCURSEL = 0x147
    $H_Return = GUICtrlSendMsg ( $H_ComboBox, $CB_GETCURSEL , 0, 0 )
    $H_ComboBox = $Array[$H_Return][1]
    Return $H_ComboBox
    Return $H_Return
EndFunc

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...