Function Reference


_GUICtrlListView_FindText

Searches for an item with the specified text

#include <GuiListView.au3>
_GUICtrlListView_FindText ( $hWnd, $sText [, $iStart = -1 [, $bPartialOK = True [, $bWrapOK = True]]] )

Parameters

$hWnd Control ID/Handle to the control
$sText Text to match
$iStart [optional] 0-based index of the item to begin the search with or -1 to start from the beginning.
The specified item is itself excluded from the search.
$bPartialOK [optional] If True, a match will occur if the item text begins with the text
$bWrapOK [optional] If True, the search will continue with the first item if no match is found

Return Value

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

Remarks

The search is case insensitive. The search is performed on the item only.
Use _GUICtrlListView_FindInText() if you want to search for the text in subitems.

Related

_GUICtrlListView_FindInText

Example

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

Example()

Func Example()
        ; Create GUI
        GUICreate("ListView Find Text (v" & @AutoItVersion & ")", 400, 300)
        Local $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
        GUISetState(@SW_SHOW)

        ; Set ANSI format
;~     _GUICtrlListView_SetUnicodeFormat($idListview, False)

        ; Add columns
        _GUICtrlListView_AddColumn($idListview, "Items", 100)

        ; Add items
        _GUICtrlListView_BeginUpdate($idListview)
        Local $iI
        For $iI = 1 To 49
                _GUICtrlListView_AddItem($idListview, "Item " & $iI)
        Next
        _GUICtrlListView_AddItem($idListview, "Target item")
        For $iI = 51 To 100
                _GUICtrlListView_AddItem($idListview, "Item " & $iI)
        Next
        _GUICtrlListView_EndUpdate($idListview)

        ; Search for target item
        $iI = _GUICtrlListView_FindText($idListview, "tArGeT")
        MsgBox($MB_SYSTEMMODAL, "Information", "Target Item Index: " & $iI)
        _GUICtrlListView_EnsureVisible($idListview, $iI)

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