展开所以节点
For i = 1 To TreeView1.Nodes.Count: TreeView1.Nodes(i).Expanded = True: Next i
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