We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Control to create a document outline

Hi,

I am looking forward to implement a document outline available in visual studio (view->otherwindows->Document Outline) which will list all the control on the designer (I have a custom designer) in a hierarchical form. I looked at a control named "Document explorer", but could not understand how this control can be used and if this can suite what I am looking for.

Thanks


1 Reply

DJ Davis Jebaraj Syncfusion Team May 29, 2012 08:34 PM UTC

Hi Bhavya,

 

You need to use a TreeView control to implement your own Document outline control. The document explorer you are referring to is specific to the Diagram control and is derived from TreeView to load nodes specific to the Diagram. Please find a code snippet of the code that parses the Diagram document and adds the representative nodes to the tree.

 

private void ParseChildren(Layer layer, TreeNode nodesParent)

        {

            foreach (INode node in layer.Nodes)

            {

                ParseNode(node, nodesParent);

            }

        }

 

        private void ParseNode(INode nodeCur, TreeNode nodesParent)

        {

            // Create corresponding TreeNode

            TreeNode nodeTreeTemp = new TreeNode(nodeCur.Name);

            nodeTreeTemp.Tag = nodeCur;

           

            // if nodeCur is CompositeNode

            // reflect its hierarchy

            if (nodeCur is ICompositeNode)

            {

                ICompositeNode nodeComposite = nodeCur as ICompositeNode;

 

                if (nodeComposite != null)

                {

                    // Parse composite node's children

                    nodeTreeTemp.ImageIndex = 2;

                    nodeTreeTemp.SelectedImageIndex = 2;

                    ParseChildren(nodeComposite, nodeTreeTemp);

                    nodeTreeTemp.Text = (nodeComposite as INode).Name + " (" + nodeComposite.ChildCount + ")";

                }

            }

            else

            {

                nodeTreeTemp.Tag = nodeCur;

                nodeTreeTemp.ImageIndex = 1;

                nodeTreeTemp.SelectedImageIndex = 1;

            }

 

            // Add created TreeNode to nodesParent

            nodesParent.Nodes.Add(nodeTreeTemp);

        }

 

 

Regards,

 

Davis


Loader.
Live Chat Icon For mobile
Up arrow icon