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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: Diagram |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

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.

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon