예제 #1
0
        private void BindingTree(Tree<Book> source)
        {
            tvProgram.SuspendLayout();
            tvProgram.Nodes.Clear();
            Book root = source.Root;
            if (null != root)
            {
                System.Windows.Forms.TreeNode node = new System.Windows.Forms.TreeNode();
                node.Text = root.Left + "-" + root.NodeName + "-" + root.Right;
                node.Tag = root;

                tvProgram.Nodes.Add(node);

                if (0 != root.ChildsCount)
                {
                    List<Book> next = source.GetNextLayer(root);
                    BuildTree(node, next, source);
                }
            }

            tvProgram.ResumeLayout(true);

            tvProgram.ExpandAll();
        }
예제 #2
0
        private void BuildTree(System.Windows.Forms.TreeNode rootNode, List<Book> next, Tree<Book> source)
        {
            if (0 != next.Count)
            {
                foreach (Book b in next)
                {
                    System.Windows.Forms.TreeNode node = new System.Windows.Forms.TreeNode();
                    node.Text = b.Left + "-" + b.NodeName + "-" + b.Right;
                    node.Tag = b;
                    rootNode.Nodes.Add(node);

                    if (0 != b.ChildsCount)
                    {
                        List<Book> nextlayer = source.GetNextLayer(b);
                        BuildTree(node, nextlayer, source);
                    }
                }
            }
        }