Draw a tree or organization chart from parent child data

有些话、适合烂在心里 提交于 2019-12-10 08:45:49

问题


I have parent-child information in a table with GroupID (TreeID.)

From this table I want to derive something like this:

The purpose of drawing a tree is for viewing only. The table has thousands of groupID/tree structures.

I am using the .NET platform.

How should I proceed?

create table parent_child (GroupID varchar(100) null,   
                           Level varchar(100) null, 
                           Name varchar(100) null,  
                           ID varchar(100) null,    
                           ParentID varchar(100) null,  
                           Top_Parent varchar(100) null)

 insert into parent_child (GroupID,Level, Name,ID,ParentID,Top_Parent) values 
     ('1234', '4', 'James', '6712', '921', '1005'), 
     ('1234', '3', 'Peter', '11', '206', '1005'),
     ('1234', '3', 'Royden', '14', '206', '1005'), 
     ('1234', '3', 'Lila', '237', '589', '1005'),
     ('1234', '3', 'Julie', '921', '589', '1005'), 
     ('1234', '2', 'Sandy', '206', '1005', '1005'), 
     ('1234', '2', 'Tom', '589', '1005', '1005'), 
     ('1234', '1', 'Sam', '1005', 'NA', '1005')

回答1:


The article A Graph Tree Drawing Control for WPF (at The Code Project) explains how to achieve what you have in mind, both in WPF and Silverlight. Kudo's to the guy who made the code available - it's well written and very easy to customize.

Screenshot from The Code Project site:

You will have to write the logic to convert your table data to a compatible data structure.

I hope the article helps!



来源:https://stackoverflow.com/questions/5667352/draw-a-tree-or-organization-chart-from-parent-child-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!