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.
Unfortunately, activation email could not send to your email. Please try again.

Is it possible to arrange/re-arrange the diagram nodes automatically in some standard manner?

 

The various diagram layout managers that are shipped with the Diagram can be used to arrange/layout the nodes in the specified format. Please refer the samples under Diagram Samples/Layout Managers category to get the details about the various layout mangers and how to use this in a diagram application to arrange the nodes.

Below code snippet shows how to apply the layout mechanism on the diagram nodes.

C#

LayoutManager manager = new DirectedTreeLayoutManager(this.diagram.Model, 0,60,80 );

this.diagram.LayoutManager = manager;

VB

Private manager As LayoutManager = New DirectedTreeLayoutManager(Me.diagram.Model, 0,60,80)

Me.diagram.LayoutManager = manager

Once the layout manager has been assigned to the diagram, we can use either the LayoutManager.UpdateLayout() or LayoutManager.AutoLayout() to arrange the nodes in the specified layout.

The following code snippet shows how to arrange the nodes that are added/present in the diagram.

C#

this.diagram.BeginUpdate();

this.diagram.LayoutManager.Nodes.Clear();

this.diagram.LayoutManager.Nodes.AddRange(this.diagram.Model.Nodes );

// Updates the layout of the nodes in the model.

this.diagram.LayoutManager.UpdateLayout(null);

this.diagram.EndUpdate();

VB

Me.diagram.BeginUpdate()

Me.diagram.LayoutManager.Nodes.Clear()

Me.diagram.LayoutManager.Nodes.AddRange(Me.diagram.Model.Nodes)

'' Updates the layout of the nodes in the model.

Me.diagram.LayoutManager.UpdateLayout(Nothing)

Me.diagram.EndUpdate()

The following code snippet shows how to arrange the nodes as soon as that are added to the diagram.

C#

this.diagram.LayoutManager.AutoLayout = true;

VB

Me.diagram.LayoutManager.AutoLayout = True

Syncfusion Inc.

Article ID: Published Date: Last Revised Date: Platform: Control:
227 04/30/2011 07/10/2014 Windows Forms Diagram
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.