Function Reference


_GUICtrlTreeView_FindItem

Retrieves a item based on it's text

#include <GuiTreeView.au3>
_GUICtrlTreeView_FindItem ( $hWnd, $sText [, $bInStr = False [, $hStart = 0]] )

Parameters

$hWnd Control ID/Handle to the control
$sText Text to search for
$bInStr [optional] If True, the text can be anywhere in the item's text.
$hStart [optional] Item to start searching from. If 0, the root item is used.

Return Value

Success: the handle of the first item that contains the item text.
Failure: 0.

Remarks

The search is case insensitive

Related

_GUICtrlTreeView_FindItemEx

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
        GUICreate("TreeView Find Item (v" & @AutoItVersion & ")", 400, 300)

        Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
        Local $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
        GUISetState(@SW_SHOW)

        ; Set ANSI format
;~     _GUICtrlTreeView_SetUnicodeFormat($idTreeview, False)

        _GUICtrlTreeView_BeginUpdate($idTreeview)
        Local $aidItem[10]
        For $x = 0 To 3
                $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
                For $y = 0 To 2
                        GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
                Next
        Next
        $aidItem[4] = GUICtrlCreateTreeViewItem(StringFormat("Looking for me?", $x), $idTreeView)
        For $x = 5 To 9
                $aidItem[$x] = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
                For $y = 0 To 2
                        GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $aidItem[$x])
                Next
        Next
        _GUICtrlTreeView_EndUpdate($idTreeview)

        Local $hItemFound = _GUICtrlTreeView_FindItem($idTreeview, "Looking for me?")
        If $hItemFound Then
                _GUICtrlTreeView_SelectItem($idTreeview, $hItemFound)
                MsgBox($MB_SYSTEMMODAL, "Information", "Item Found:" & @CRLF & "Handle: " & $hItemFound & @CRLF & "Text: " & _GUICtrlTreeView_GetText($idTreeview, $hItemFound))
        Else
                MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Information", "Not Found")
        EndIf

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