本文介绍了填充树视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!我怎么能用这个填充树形视图:ObservableCollection< ProjectTreeview> trvProject = 新 ObservableCollection< ProjectTreeview>() { 新建 ProjectTreeview(){ID = 1 ,ParentID = 0 ,类型= " P" ,名称= " 项目名称" }, 新建 ProjectTreeview(){ID = 2 ,ParentID = 1 ,类型= " F" ,名称= " 字段1" }, 新建 ProjectTreeview(){ID = 3 ,ParentID = 1 ,类型= " F" ,名称= " 字段2" }, 新建 ProjectTreeview(){ID = 4 ,ParentID = 2 ,类型= " S" ,名称= " 结构A" }, 新建 ProjectTreeview(){ID = 5 ,ParentID = 3 ,类型= " S" ,名称= " 结构B" }, 新建 ProjectTreeview(){ID = 6 ,ParentID = 4 ,类型= " C" ,名称= " 组件A1" }, 新建 ProjectTreeview(){ID = 7 ,ParentID = 5 ,类型= " C" ,名称= " 组件B1" }, 新建 ProjectTreeview(){ID = 8 ,ParentID = 6 ,类型= " CA1" ,名称= " 组件A2" }, 新建 ProjectTreeview(){ID = 9 ,ParentID = 7 ,类型= " CB1" ,名称= " 组件B2" } };
层次结构基于ParentID.谢谢:)
解决方案
hi! how can i populate a treeview with this:
ObservableCollection<ProjectTreeview> trvProject = new ObservableCollection<ProjectTreeview>() { new ProjectTreeview(){ID=1, ParentID=0, Type="P", Name="Project Name"}, new ProjectTreeview(){ID=2, ParentID=1, Type="F", Name="Field 1"}, new ProjectTreeview(){ID=3, ParentID=1, Type="F", Name="Field 2"}, new ProjectTreeview(){ID=4, ParentID=2, Type="S", Name="Structure A"}, new ProjectTreeview(){ID=5, ParentID=3, Type="S", Name="Structure B"}, new ProjectTreeview(){ID=6, ParentID=4, Type="C", Name="Component A1"}, new ProjectTreeview(){ID=7, ParentID=5, Type="C", Name="Component B1"}, new ProjectTreeview(){ID=8, ParentID=6, Type="CA1", Name="Component A2"}, new ProjectTreeview(){ID=9, ParentID=7, Type="CB1", Name="Component B2"} };
The heirarchy is based on the ParentID. Thanks :)
解决方案
这篇关于填充树视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!