to hellmaster(李晋):
程序如下,功能实现了,再次感谢你的帮助
Private Function GetNode(ByVal obj As TreeNodeCollection, ByVal txt As Integer) As TreeNode
Dim tNode As New TreeNode()
Dim oldnode As TreeNode
For Each tNode In obj
If CInt(Trim(tNode.Tag)) = txt Then
Return tNode
Else
If tNode.Nodes.GetEnumerator.MoveNext() Then
oldnode = GetNode(tNode.Nodes, txt)
If Not IsNothing(oldnode) Then
Return oldnode
End If
End If
End If
Next
' Return oldnode
End Function
下面就以text属性为例,
Private Function GetNode(ByVal obj As TreeNodeCollection, ByVal txt As String) As Object
Dim tNode As New TreeNode
For Each tNode In obj
If Trim(tNode.Text) = txt Then
Return tNode
Else
If tNode.Nodes.GetEnumerator.MoveNext() Then
Return GetNode(tNode.Nodes, txt)
End If
End If
Next
End Function
调用方法:
假设你的TreeView名为TreeView1,要查找的Text为"findtext",
Dim obj As Object