请教如何判断treeview 里的根数量(既有几个根目录),谢谢!!!!

解决方案 »

  1.   

    dim nodex as node
    dim i as integer
    i=0
    for each nodex in treeview1.nodes
        if nodex.Parent="" then
           i=i+1
        endif
    nextmsgbox i
      

  2.   

    也可通过在建树时标识不同的关键字  如根结点以Root开头 子结点以Sub开头
      

  3.   

    dim iCount as integer
    dim tnode as node
    icount=0
    with treeview1
      for each tnode in .nodes.  
         if tnodes(i).parent is nothing then
            icount=icount+1
         endif
      next 
    end withmsgbox "共有" & icount & "个根节点!"