TreeView展开所有节点

Posted 死鱼眼の猫

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TreeView展开所有节点相关的知识,希望对你有一定的参考价值。

 1 private void ExpandAllFolder(GsTreeListViewItem aItem)        
 2 {
 3   if (aItem == null) return;
 4   CPlanContentAndOrder ItemPlan = aItem.Header as CPlanContentAndOrder;
 5   if (ItemPlan.iType != (int)TPlanNodeType.EFolder) return;
 6   aItem.IsExpanded = true;
 7   if (aItem.ItemContainerGenerator.Status != System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
 8   {
 9      //生成子节点
10     aItem.ItemContainerGenerator.StatusChanged += new EventHandler(delegate
11       {
12             if (aItem.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
13             {
14                for (int i = 0; i < aItem.Items.Count; i++)
15                 {
16             GsTreeListViewItem item = aItem.ItemContainerGenerator.ContainerFromIndex(i) as GsTreeListViewItem;
17             ExpandAllFolder(item);
18                }
19         }
20       });
21   }
22   else
23   {
24     for (int i = 0; i < aItem.Items.Count; i++)
25     {
26           GsTreeListViewItem item = aItem.ItemContainerGenerator.ContainerFromIndex(i) as GsTreeListViewItem;
27           ExpandAllFolder(item);
28        }
29   }
30 }

 

以上是关于TreeView展开所有节点的主要内容,如果未能解决你的问题,请参考以下文章

winform中,TreeView如何只展开一级节点

C# winform treeview 节点展开状态的图标设置

关于c#中treeview节点的收缩与展开(.net web)

如何在窗体初始化的时候就展开所有TreeView控件的所有节点

C# winform 中展开Treeview节点的问题。。。有分

ASP中关于TreeView控件的问题,怎样展开、收缩所有子节点?