以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何让TreeView一级根目录和二级根目录分开 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=145534) |
||||
-- 作者:hongye -- 发布时间:2020/1/28 17:18:00 -- 如何让TreeView一级根目录和二级根目录分开 For Each frm As WinForm.Form In Forms If lsu.Nodes.Contains(frm.Category) = False Then lsu.Nodes.Add(frm.Category) End If lsu.Nodes(frm.Category).Nodes.Add(frm.name) Next |
||||
-- 作者:程兴刚 -- 发布时间:2020/1/28 22:17:00 -- 发文件! |
||||
-- 作者:hongye -- 发布时间:2020/1/29 10:31:00 --
[此贴子已经被作者于2020/1/29 10:34:19编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2020/1/29 14:08:00 -- Dim lsu As WinForm.TreeView = Forms("窗口9").Controls("TreeView1") lsu.Nodes.Clear Dim dict As new Dictionary(of String,WinForm.TreeNode ) For Each frm As WinForm.Form In Forms If frm.Category > "" If dict.ContainsKey(frm.Category) = False Then Dim ar() As String = frm.Category.Split("\\") Dim n As WinForm.TreeNode If lsu.Nodes.Contains(ar(0)) n = lsu.Nodes(ar(0)) Else n = lsu.Nodes.Add(ar(0),ar(0)) End If Dim i As Integer = 1 Do While i < ar.Length If n.Nodes.Contains(ar(i)) n = n.Nodes(ar(i)) Else n = n.Nodes.Add(ar(i),ar(i)) End If i += 1 Loop dict.Add(frm.Category,n) End If dict(frm.Category).Nodes.Add(frm.name) Else lsu.Nodes.Add(frm.name) End If Next
|