Function Reference


_GUICtrlComboBoxEx_FindStringExact

Search for a string

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

Parameters

$hWnd 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

Find the first string that matches the string specified in the $sText parameter.

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 <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
        Local $hGUI, $hImage, $sDelimiter = ";", $hCombo

        Opt("GUIDataSeparatorChar", $sDelimiter)

        ; Create GUI
        $hGUI = GUICreate("ComboBoxEx Find String Exact", 400, 300)
        $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "This is;mY tExT", 2, 2, 394, 100, $CBS_SIMPLE)
        GUISetState(@SW_SHOW)

        $hImage = _GUIImageList_Create(16, 16, 5, 3)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
        _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
        _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0xFF0000, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x00FF00, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap($hCombo, 0x0000FF, 16, 16))
        _GUICtrlComboBoxEx_SetImageList($hCombo, $hImage)

        _GUICtrlComboBoxEx_BeginUpdate($hCombo)
        For $x = 0 To 8
                _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
        Next
        _GUICtrlComboBoxEx_EndUpdate($hCombo)

        ; Find exact string
        MsgBox($MB_SYSTEMMODAL, "Information", "Found at: " & _GUICtrlComboBoxEx_FindStringExact($hCombo, "mY tExT"))

        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example