码迷,mamicode.com
首页 > 其他好文 > 详细

TreeView展开所有节点

时间:2018-03-30 20:04:17      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:+=   div   emc   and   style   delegate   null   list   contain   

 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展开所有节点

标签:+=   div   emc   and   style   delegate   null   list   contain   

原文地址:https://www.cnblogs.com/qiups/p/8677917.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!