友好一点吗,treeview不是很好的空间嘛!
循环比对一下不就可以了吗!

解决方案 »

  1.   

    很简单,错误捕捉吗
    例如
    Private Function GetTreeNode(XtKey As String) As MSComctlLib.Node
    On Error GoTo DoNoNode
        Set GetTreeNode = TreeView1.Nodes(XtKey)
        Exit Function
    DoNoNode:
        Set GetTreeNode = Nothing
        Resume Next
    End Function调用 GetTreeNode 返回 nothing 不存在
    if GetTreeNode is nothing then
        msgbox "no the Node"
    end if
      

  2.   

    '不用错误处理
    Public Function IsExistNode(sKeyOfNode As String, TreeViewX As MSComctlLib.TreeView) As Boolean
    Dim i As Long
    For i = 0 To TreeViewX.Nodes.Count - 1
        If TreeViewX.Nodes.Item(i + 1).Key = sKeyOfNode Then
           IsExistNode = True
           Exit For
        End If
    Next
    End Function
      

  3.   

    你想用treeview实现什么应用呢?