以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  如何判断目录树当前可见节点数量  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=124690)

--  作者:ZJZK2018
--  发布时间:2018/9/12 0:55:00
--  如何判断目录树当前可见节点数量
需求:根据可见节点数自动设置分区面板的高度

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each nd As WinForm.TreeNode In trv.AllNodes
    If nd.EnsureVisible
        msgbox(nd.Nodes.Count)
        e.Form.Controls("SplitContainer1").SplitterDistance = nd.Nodes.Count *20
    End If
Next

[此贴子已经被作者于2018/9/12 1:02:50编辑过]

--  作者:有点甜
--  发布时间:2018/9/12 9:16:00
--  

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim sum As Double = 0
For Each nd As WinForm.TreeNode In trv.AllNodes
    If nd.IsExpanded Then
        sum += nd.Nodes.Count
    End If
Next
msgbox(sum+trv.Nodes.count)