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

How to change text color in a Node?

Thread ID:





75069 Jul 10,2008 04:03 PM UTC Jul 15,2008 04:30 AM UTC ASP.NET Web Forms (Classic) 2
Tags: DiagramWebControl
Administrator [Syncfusion]
Asked On July 10, 2008 04:03 PM UTC

I'm having a problem programatically changing the color of the text of a label in a Node on in my diagram. I have looked for a property for text color in both the Label and RoundRect classes but do not see properties to set text color?


J.Nagarajan [Syncfusion]
Replied On July 14, 2008 01:53 PM UTC

Hi bbarnard ,

Sorry for the inconvenience caused. You can not set the text color to the labels. Please use our TextNode instead. You can group the textnode on the RoundedRect and display the text as the label.

TextNode n = new TextNode("Novo texto");
//To set TextColor.
n.FontColorStyle.Color = Color.Green;
n.PinPoint=new PointF(200, 200);
n.Size=new SizeF(100,40);
n.EnableCentralPort = true;
n.WrapText = true;

Please let me know if this helps.


J.Nagarajan [Syncfusion]
Replied On July 15, 2008 04:30 AM UTC

Hi Bryan ,

To change the TextColor of a node, you have to derive the Label class and override the Render() method. You can change the text color in this Render() method. Please refer to the following code snippet.

class MyLabel:Label
public MyLabel(string Text)
this.Text = Text;

m_strText = this.Text;

protected override void Render(System.Drawing.Graphics gfx)

// calc position
PointF ptPrimitivePosition = GetPosition();

using (Font font = this.FontStyle.CreateFont())
// get string bounding rectangle
SizeF szStringSize = gfx.MeasureString(m_strText, font);
PointF ptRenderringOrigin = new PointF(ptPrimitivePosition.X - szStringSize.Width / 2
, ptPrimitivePosition.Y - szStringSize.Height / 2);
// draw text
gfx.DrawString(this.Text, font, new SolidBrush(Color.Green), ptRenderringOrigin.X, ptRenderringOrigin.Y);

//Add the CustomLabel to the node

Rectangle m_rect1 = new Rectangle(120, 90, 120, 60);
Label m_Label = new MyLabel("CustomLabel");
m_Label.Position = Position.Center;

Please use this code and let me know if this helps.



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