G
gaxjyxq
Guest
I have AdvTree control and the tree list is multi-level struct, now I need to build the search function to loop through all nodes using the recursive function, hide the nodes that not matched searched value. But how to only keep the matched tree list? The code is below.
Private Sub FilterAllNodes(ByVal objNC As NodeCollection, ByVal ComparedString As String)
Dim nodeMatched As Boolean
For Each node As Node In objNC
If node.HasChildNodes = False Then
If Node.text=ComparedString Then
nodeMatched = True
End If
node.Visible = nodeMatched
Else
FilterAllNodes(node.Nodes, ComparedString)
End If
Next
End Sub
View the image below, only remain the red region.
Continue reading...
Private Sub FilterAllNodes(ByVal objNC As NodeCollection, ByVal ComparedString As String)
Dim nodeMatched As Boolean
For Each node As Node In objNC
If node.HasChildNodes = False Then
If Node.text=ComparedString Then
nodeMatched = True
End If
node.Visible = nodeMatched
Else
FilterAllNodes(node.Nodes, ComparedString)
End If
Next
End Sub
View the image below, only remain the red region.
Continue reading...