allbluekos 2015-06-11 08:08 采纳率: 88.5%
浏览 1572
已采纳

在TREEVIEW中查找值等于TEXTBOX的值

如题,在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
图片说明

  • 写回答

3条回答 默认 最新

  • Tiger_Zhao 2015-06-11 09:10
    关注

    If tn.Text Like "*" & text.Trim() & "*" Then
    Like需要有通配符啊。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用