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

Correct way to resize nodes after creation

Thread ID:





101095 Sep 26,2011 05:40 PM UTC Sep 29,2011 02:05 PM UTC WinForms 4
Tags: Diagram
Johnathan Tunnicliffe
Asked On September 26, 2011 05:40 PM UTC

Hi Syncfusion,

Can you advise on the correct way to set the size of a node AFTER it's already been created (and given an initial size)? I've managed to use the below code to do it but i get strange positioning of highlight boxes when adding links once it's been resized.

Here's the code i was using to resize the nodes:
// create node
var n = new Rectangle(10,10,265,100,MeasureUnits.Pixel);
// to shrink
n.SetSize(new SizeF(265,100), new SizeF(265,60)); // old size followed by new size
n.CentralPort.OffSetX = 265/2;
n.CentralPort.OffsetY = 60/2;
// to expand
n.SetSize(new SizeF(265,60), new SizeF(265,100)); // new size followed by old size
n.CentralPort.OffSetX = 265/2;
n.CentralPort.OffsetY = 100/2;

Can somebody advise what I should be doing instead?

Thank you,


Amsath Ali M [Syncfusion]
Replied On September 27, 2011 06:24 AM UTC

Hi Johnathan,

Thanks for your interest in Syncfusion products.

We suggest you to use the Node’s ‘Size’ property to change the size of the node after creating the node. Since the central port is automatically positioned in the center of the node when node’s size is changed, you need not to change its offsets. Please refer the below code snippet to achieve your requirement.

Here is the code:
//Gets/Sets the size of the node.
node.Size = new SizeF(70, 50);

For your convenience, we have created a simple sample to achieve your requirement.
Please try the below sample and let us know if you have any queries.
Forum set node size2058710948.zip

Amsath Ali. M

Johnathan Tunnicliffe
Replied On September 27, 2011 08:08 AM UTC

Hi Amsath Ali. M,

I had tried that before but for some reason the node isn't being having it's size property changed. I'm setting the size of the node in the setter of a property on the node itself.

I've overriden Rectangle and have a boolean property called ConciseMode. It's implementation looks like this:

private bool m_conciseMode;
public bool ConciseMode
get { return m_conciseMode; }
set {
this.Size = new SizeF(265, 60);
this.Size = new SizeF(265, 100);

// whilst stepping over the code i can see the size of 'this' hasn't changed
m_conciseMode = value;

any idea why this could be happening whilst .SetSize appears to have an impact no the size?


Johnathan Tunnicliffe
Replied On September 27, 2011 08:16 AM UTC

I've just figured out what it is.

I had the follwing properties set:
//this.EditStyle.AllowChangeHeight = false;
//this.EditStyle.AllowChangeWidth = false;

This is because i didn't want the user to be able to resize the nodes. But i did not realize it would mean i can't set the node size programatically. Is this also the case with AllowMoveX and AllowMoveY that I then can't programmatically move nodes (but want the users to not be able to drag the node)?


Amsath Ali M [Syncfusion]
Replied On September 29, 2011 02:05 PM UTC

Hi Johnathan,

Thanks for the update.

When the Node.Editstyle’s “AllowChangeWidth and AllowChangeHeight” properties are set to ‘false’ then the node cannot be resized either by programmatically or by dynamically through by dragging the resize handle of node. Hence, we suggest you to set those Properties to ‘true’ before changing the size of the node by programmatically.
Please let us know if you have any queries.

Amsath Ali. M


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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