Jump to content

Autocomplete Combobox


Recommended Posts

I would like to use the Autocomplete function for the combobox, but I don't know how.

; Create a GUI with various controls.
Local $hGUI = GUICreate("Find Computer Owner", 300, 200)

; Create a combobox control.
Local $idComboBox = GUICtrlCreateCombo("", 2, 2, 296, 20)
Local $idMylist = GUICtrlCreateList("", 2, 24, 296, 140)
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
Local $idClos = GUICtrlCreateButton("Close", 210, 170, 85, 25)
_AD_Open()
; Add files
_GUICtrlComboBox_BeginUpdate($idComboBox)
Local $sFill = ""
For $i = 0 to UBound($aNames) -1
    Local $aUserInfo = _AD_GetObjectsInOU($aNames[$i],"","","displayName,distinguishedName")
;_ArrayDisplay($aUserInfo)
    for $x = 1 To $aUserInfo[0][0]
        If $aUserInfo[$x][0] <> "" Then
            $sFill &= $aUserInfo[$x][0] & " ; " & $aUserInfo[$x][1] & "|"
        EndIf
    Next
;       _ArrayDisplay($aUser,"1")
Next
$sFill = StringTrimRight($sFill, 1)
GUICtrlSetData($idComboBox, $sFill, "")
_GUICtrlComboBox_EndUpdate($idComboBox)
   ; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
Local $sComboRead = ""
; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idClos
            ExitLoop
        Case $idComboBox
            $sComboRead = GUICtrlRead($idComboBox)
            $sComboRead = StringTrimLeft($sComboRead,StringInStr($sComboRead,';'))
            $aComputerOwner = _AD_GetObjectsInOU("OU=Firm,DC=AD,DC=Firm,DC=ORG","(&(objectclass=computer)(managedby=" & $sComboRead & "))",Default,"cn")
            If $aComputerOwner <> "" Then
                For $i = 1 to $aComputerOwner[0]
                    GUICtrlSetData($idMylist, $aComputerOwner[$i] & "|")
                Next
            Else
                GUICtrlSetData($idMylist, "No computer|")
            EndIf
    EndSwitch
WEnd
_AD_Close()

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

Can someone guide me?

Yours sincerely

Kenneth.

Link to comment
Share on other sites

  • 1 year later...

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

×
×
  • Create New...