There's probably a better way but this is my attempt
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <guitreeview.au3>
Opt('GUIOnEventMode', 1)
GUICreate("Form1", 528, 298)
GUISetOnEvent($GUI_EVENT_CLOSE, 'ProgramClose')
Global $h_Next = 0
Global $i_TreeViewID = GUICtrlCreateTreeView(8, 8, 505, 193)
Global $i_SearchInputID = GUICtrlCreateInput("Type the name to search", 184, 216, 153, 21)
GUICtrlCreateButton("Search", 184, 248, 155, 25)
GUICtrlSetOnEvent(-1, 'FindSelectedItem')
LoadTreeView() ; load the treeview
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func FindSelectedItem()
Local $h_SearchItem = _GUICtrlTreeView_FindItem($i_TreeViewID, GUICtrlRead($i_SearchInputID), True, $h_Next)
_GUICtrlTreeView_SelectItem($i_TreeViewID, $h_SearchItem)
_GUICtrlTreeView_EnsureVisible($i_TreeViewID, $h_SearchItem)
If Not $h_SearchItem Then
$h_Next = 0
MsgBox(0, 'That''s All Folks', 'All search strings found')
Else
$h_Next = _GUICtrlTreeView_GetNext($i_TreeViewID, $h_SearchItem)
EndIf
EndFunc ;==>FindSelectedItem
Func LoadTreeView()
_GUICtrlTreeView_BeginUpdate($i_TreeViewID)
Local $i_ParentID = GUICtrlCreateTreeViewItem("First", $i_TreeViewID)
For $i = 1 To 15
GUICtrlCreateTreeViewItem($i, $i_ParentID)
GUICtrlSetOnEvent(-1, 'UpdateSearchBox')
Next
$i_ParentID = GUICtrlCreateTreeViewItem("Second", $i_TreeViewID)
For $i = 16 To 30
GUICtrlCreateTreeViewItem($i, $i_ParentID)
GUICtrlSetOnEvent(-1, 'UpdateSearchBox')
Next
_GUICtrlTreeView_EndUpdate($i_TreeViewID)
EndFunc ;==>LoadTreeView
Func UpdateSearchBox()
If Not $h_Next Then GUICtrlSetData($i_SearchInputID, _GUICtrlTreeView_GetText($i_TreeViewID, GUICtrlRead($i_TreeViewID)))
EndFunc ;==>UpdateSearchBox
Func ProgramClose()
Exit
EndFunc ;==>ProgramClose