以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- treeview控件宽度 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=191378) |
-- 作者:lur320 -- 发布时间:2024/4/13 14:11:00 -- treeview控件宽度 如何遍历nodes,然后调整treeview的宽度,确保最右边的node能露出来,底部没有滚动条? |
-- 作者:有点蓝 -- 发布时间:2024/4/13 15:40:00 -- Dim t As WinForm.TreeView = Forms("窗口3").Controls("TreeView1") t.CollapseAll t.SelectedNode = t.Nodes(0) t.ExpandAll Dim tn As WinForm.TreeNode = t.SelectedNode Dim level As Integer = 0 For Each n As WinForm.TreeNode In t.AllNodes If n.Nodes.Count = 0 AndAlso n.Level > level Then tn = n level = n.Level End If Next Dim trv = t.BaseControl Dim rg = trv.rectangletoscreen(tn.BaseNode.bounds) Dim rg2 = Forms("窗口3").panel.rectangletoscreen(trv.bounds) If rg.Right > rg2.Right Then t.width = rg2.width + rg.Right - rg2.Right + 2 End if |