Foxtable(狐表)用户栏目专家坐堂 → 请教:在treeview 中打开一个节点,如何做到同时关闭其他节点?


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

主题:请教:在treeview 中打开一个节点,如何做到同时关闭其他节点?

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


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

获取父节点:http://www.foxtable.com/webhelp/topics/1498.htm

到AfterExpandNode事件遍历当前节点的父节点的所有子节点,如果不是当前节点就收缩

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


加好友 发短信
等级:超级版主 帖子:113732 积分:579221 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/3/27 16:18:00 [显示全部帖子]

先自己写,哪里有问题再把代码发上来看看

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


加好友 发短信
等级:超级版主 帖子:113732 积分:579221 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/3/28 11:00:00 [显示全部帖子]

Dim pd As WinForm.TreeNode = e.node.ParentNode
if pd is nothing then 
For Each nd As WinForm.TreeNode In e.sender.nodes
    If nd.name <> e.node.name Then
        nd.CollapseAll()
    End If
Next
else
For Each nd As WinForm.TreeNode In pd.nodes
    If nd.name <> e.node.name Then
        nd.CollapseAll()
    End If
Next
end if

 回到顶部