Function Reference


_GUICtrlComboBox_FindString

Search for a string

#include <GuiComboBox.au3>
_GUICtrlComboBox_FindString ( $hWnd, $sText [, $iIndex = -1] )

Parameters

$hWnd Control ID/Handle to the control
$sText String to search for
$iIndex [optional] 0-based index of the item preceding the first item to be searched

Return Value

Success: a 0-based index of the matching item.
Failure: -1.

Remarks

Finds the first string beginning with the characters specified in $sText.

When the search reaches the bottom of the ListBox, it continues from the top of the ListBox back to the item specified by $iIndex.

If $iIndex is –1, the entire ListBox is searched from the beginning.

Related

_GUICtrlComboBox_SelectString

Example

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
        Local $idCombo

        ; Create GUI
        GUICreate("ComboBox Find String", 400, 296)
        $idCombo = GUICtrlCreateCombo("", 2, 2, 396, 296)
        GUISetState(@SW_SHOW)

        ; Add files
        _GUICtrlComboBox_BeginUpdate($idCombo)
        _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES, False)
        _GUICtrlComboBox_AddString($idCombo, "This is a test")
        _GUICtrlComboBox_AddDir($idCombo, "", $DDL_DRIVES)
        _GUICtrlComboBox_EndUpdate($idCombo)

        ; Find string
        MsgBox($MB_SYSTEMMODAL, "Information", "Find String: " & _GUICtrlComboBox_FindString($idCombo, "this"))

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>Example