private void build( TreeNodeCollection from , TreeNodeCollection to , TreeNode parent ) { TreeNodeCollection childNodes = from.SearchByParentId( parent.Id ) ; foreach( TreeNode n in childNodes ) { to.Add(n); this.build( from , n.ChildNodes , n ) ; } }
private TreeNodeCollection GetRootNodes( TreeNodeCollection nodes ) { TreeNodeCollection tempnodes = new TreeNodeCollection (); foreach( TreeNode n in nodes ) { if( nodes.ExistByParentId( n.Id ) ) tempnodes.Add(n); } return tempnodes ; }
public void BuildNodes( TreeNodeCollection nodes , System.Collections.IEnumerable list ) { TreeNodeCollection tempnodes = new TreeNodeCollection (); System.Collections.IEnumerator lt = list.GetEnumerator(); while( lt.MoveNext() ) { object o = lt.Current ; tempnodes.Add( _c.ToTreeNode( o ) ); } TreeNodeCollection roots = this.GetRootNodes( tempnodes ) ; foreach( TreeNode n in roots ) { nodes.Add( n ); this.build( tempnodes , n.ChildNodes , n ) ; } }
public TreeNodeCollection SearchByParentId( string parentId ) { TreeNodeCollection nodes = new TreeNodeCollection (); foreach( TreeNode n in this ) { if( n.ParentId == parentId ) nodes.Add( n ) ; } return nodes ; }
public bool ExistByParentId( string pid ) { TreeNodeCollection nodes = new TreeNodeCollection (); foreach( TreeNode n in this ) { if( n.ParentId == pid ) return true ; } return false ; }