注册 登录
编程论坛 VB6论坛

TreeView 子节点有项被选中,展开父节点

sdgzs 发布于 2023-05-02 10:43, 819 次点击
TreeView 加载时 子节点有项被选中,展开父节点,求代码,多谢帮助。

只有本站会员才能查看附件,请 登录
2 回复
#2
wds12023-05-02 17:09
展开所以节点
For i = 1 To TreeView1.Nodes.Count: TreeView1.Nodes(i).Expanded = True: Next i
#3
东海ECS2023-05-02 17:31
Private SubTreeView1_Initialize() Dim Node As Node For Each Node In TreeView1.Nodes ExpandParentIfChildSelected Node Next End Sub Private Sub ExpandParentIfChildSelected(Node As Node) Dim ChildNode As Node For Each ChildNode In Node.Children If ChildNode.Selected Then Node.Expanded = True ExpandParentIfChildSelected Node.Parent Exit For End If ExpandParentIfChildSelected ChildNode Next End Sub
1