我写了个 ListSub(1)方法 用来取出每层数据实体 参数1是最上层的ID
可是我扣了一晚上代码 还是不知道如何绑定到 orgchart上
下面的代码应该如何修改 还有 c1OrgChart1.Header = 这里怎么写啊?
老大帮帮忙吧 真的 很急
public static void ListSub(int id)
{
Team obj = TeamList().Where(u => u.ID == id).FirstOrDefault();
if (obj == null)
{
return;
}
else
{
List<Team> objs = TeamList().Where(u => u.Fid == obj.ID).ToList();
foreach (Team role in objs)
{
obj.Challengers.Add(role);
// MessageBox.Show(obj.Name+"--"+role.Name);
ListSub(role.ID); //每个子集递归
}
}
}
public static List<Team> TeamList()
{
List<Team> source = new List<Team>();
source.Add(new Team() { ID = 1, Name = "刘华强", Position = "董事长", Fid = 0 });
source.Add(new Team() { ID = 2, Name = "赵晓华", Position = "产品经理", Fid = 1 });
source.Add(new Team() { ID = 3, Name = "刘宗敏", Position = "项目经理", Fid = 1 });
source.Add(new Team() { ID = 4, Name = "林志玲", Position = "产品经理秘书", Fid = 2 });
source.Add(new Team() { ID = 5, Name = "刘德华", Position = "技术员", Fid = 3 });
source.Add(new Team() { ID = 6, Name = "张学友", Position = "技术员", Fid = 3 });
source.Add(new Team() { ID = 7, Name = "谭咏麟", Position = "初级技术员", Fid = 6 });
return source;
} |