如題,在TEXTBOX中輸入一個值,按查找按鈕,在樹中找到並高亮顯示,沒有實現,請幫忙看看如下代碼,看怎麼修改:
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim tnc As TreeNode
For Each tnc In TreeView1.Nodes
nextnodes(tnc, TextBox7.Text)
Next
End Sub
Public Sub nextnodes(ByVal node As TreeNode, ByVal text As String)
Dim tn As TreeNode
For Each tn In node.Nodes
If tn.Text Like text.Trim() Then
tn.BackColor = Drawing.Color.YellowGreen
shownodes(tn)
End If
nextnodes(tn, text)
Next
End Sub
Public Sub shownodes(ByVal node As TreeNode)
If IsDBNull(node) = False Then
node.Expand()
shownodes(node.Parent)
End If
End Sub
If tn.Text Like "*" & text.Trim() & "*" Then
Like需要有通配符啊。