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.

In the textnode how to get the height by width and font size?

Thread ID:





101847 Nov 26,2011 07:34 AM Dec 2,2011 12:55 AM Windows Forms 4
Tags: Diagram
Asked On November 26, 2011 07:34 AM

In the textnode how to get the height by width and font size?

Amsath Ali M [Syncfusion]
Replied On November 28, 2011 05:44 AM

Hi Songjian,

Thanks for your interest in Syncfusion products.

We suggest you to use the TextNode.BoundingRectangle’s ‘Width and Height’ properties to get height and width of the node respectively and use TextNode.FontStyle’s ‘Size’ property to get the size of the font in TextNode. Please refer the below code snippet to achieve your requirement.

Here is the code:
//Getting TextNode's properties in ButtonClick
private void button1_Click(object sender, EventArgs e)
if (diagram1.View.SelectionList.Count != 0)
foreach (Node node in diagram1.View.SelectionList)
if (node is TextNode)
float width = ((TextNode)node).BoundingRectangle.Width;
float height = ((TextNode)node).BoundingRectangle.Height;
float fntSize = ((TextNode)node).FontStyle.Size;
MessageBox.Show("Width:" + width + " " + "Height:" + height + " " + "Font Size:" + fntSize);
MessageBox.Show("Please select a TextNode");

Here is the Sample:

Please try the above sample and let us know if you have any queries.

Amsath Ali. M

Replied On November 28, 2011 09:25 AM

When there are one more space in the textnode and I set the wrap property of textnode and the text length exceeds the textnode width,the line wrap exists.I don't to expect lines warp,how to solve it.Thank you!

Replied On November 28, 2011 09:38 AM

Sorry, I think I can't accurately express my question. My question is that how to get the textnode height when the textnode width and font size is known.Thank you!

Pandi Murugan A [Syncfusion]
Replied On December 2, 2011 12:55 AM

Hi Songjian,

We regret for the delay in getting back to you.

Please note that the TextNode’s Width/Height are not related to font size and they return Node’s bounds size. You can get the TextNode’s height by either BoundingRectangle.Height or TextNode.Size.Height.

Please let me know if you have any concerns.

Pandi Murugan A


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.

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.