[RESOLVED] Treenode search
I know that I can use treeview.nodes.find() but that will find the exact text so how would I search a treeview to find like items?
I have come close but this only searches the parents, never the children. Would I have to do a double search, start at parent and then get all nodes in parent?
Code:
Private Function SearchTree(ByVal sSearchString As String) As Boolean
Dim l As Integer
Dim n As TreeNode
'Dim sSearchString As String
For Each n In FrmMain.tvwMain.Nodes("RecipeBank").Nodes
'MsgBox(n.Text)
If CBool(InStr(1, n.Text, sSearchString, vbTextCompare)) Then
FrmMain.tvwMain.SelectedNode = n
'MsgBox(FrmMain.tvwMain.SelectedNode)
SearchTree = True
lLastNodeFound = l
'or call the click event : TreeView1_NodeClick n
Exit Function
End If
Next
SearchTree = False
lLastNodeFound = 0
End Function