hroberts

2 Column Array into a GUI

3 posts in this topic

I have a 2 column array.  Column 1 is the Name of an OU, column 2 is the FQDN.  I want to bring the information from this array into the ComboBox, displaying column 1, but selecting column 2 to be used further in the script.  I believe I have to extract the 2 columns into 2 different arrays but I am not sure how/what to do to get this to work.  Can anyone help me out with getting this to work?

 

Thanks,

Share this post


Link to post
Share on other sites



This might help you

Global $aData[3][2]
 ; this array contains OU and FQDN
Global $sComboData=""
For $i=0 To 2
 ;just to populate array quickly
    $aData[$i][0]="OU" & $i
    $aData[$i][1]="FQDN" & $i
    $sComboData=$sComboData & $aData[$i][0] & "|"
Next

$hMain=GUICreate("Test")
$idCombo=GUICtrlCreateCombo("",10,10)
GUICtrlSetData($idCombo,$sComboData)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $idCombo
            $sTextSelected=GUICtrlRead($idCombo)
 ;when selection occurs get the text that is displayed
            $iFoundItem=-1
            For $i=0 To UBound($aData,1)-1 ; search for selected text in array of your data
                If $sTextSelected==$aData[$i][0] Then
                    $iFoundItem=$i ; store the index where we found our selection for further use if necessary 
                    ConsoleWrite("OU=" & $sTextSelected & ", FQDN=" & $aData[$i][1] & @CRLF)
                EndIf
            Next
    EndSwitch
WEnd

You could have posted some code ;)

Share this post


Link to post
Share on other sites

Fill the combobox with the elements from column 1. When a user selects an entry you get the displayed text in return. With this text loop through the array and grab the corresponding text from column 2.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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