如题,在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
在TREEVIEW中查找值等于TEXTBOX的值
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- Tiger_Zhao 2015-06-11 09:10关注
If tn.Text Like "*" & text.Trim() & "*" Then
Like需要有通配符啊。本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报