Foxtable(狐表)用户栏目专家坐堂 → 目录树问题?


  共有3141人关注过本帖树形打印复制链接

主题:目录树问题?

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107754 积分:548109 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/9/4 14:05:00 [显示全部帖子]

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each nd As WinForm.TreeNode In trv.AllNodes
    If nd.Level = e.Node.Level AndAlso nd.FullPath <> e.Node.FullPath then
        nd.Collapse()
    End If
Next
e.Node.Expand()

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107754 积分:548109 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/9/4 14:09:00 [显示全部帖子]

这样效率更高,至于为什么,自己思考一下

If e.Node.parentnode IsNot Nothing Then
    For Each nd As WinForm.TreeNode In e.Node.parentnode.nodes
        nd.Collapse()
    Next
Else
    For Each nd As WinForm.TreeNode In e.sender.nodes
        nd.Collapse()
    Next
End If
e.Node.Expand()

 回到顶部
帅哥,在线噢!
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107754 积分:548109 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/9/4 15:00:00 [显示全部帖子]

去掉e.Node.Expand()

 回到顶部