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. Image for the cookie policy date

How do I create a label wider/longer than the symbol to which it is attached.

I am currently using something like:


               

public void updateNodeLabel(Node n)

{

     if (n.GetType() == typeof(Ellipse))

{

Ellipse e = (Ellipse)n;

e.Labels.Clear();

WorkUnit wu = (WorkUnit)n.Tag;

string str0 = wu.Name;

Syncfusion.Windows.Forms.Diagram.Label label0 = new Syncfusion.Windows.Forms.Diagram.Label(n, str0);

label0.Position = Syncfusion.Windows.Forms.Diagram.Position.Custom;

label0.OffsetX = (float)(n.BoundingRectangle.Width / 2);

label0.OffsetY = (float)(n.BoundingRectangle.Height / 2) - 20;

label0.FontStyle.Family = defaultDiagramLabelFont;

label0.FontStyle.Size = defaultDiagramLabelSize;

e.Labels.Add(label0);

}

}


However, the program prints the label with a bounding box the same width as the ellipse. This is not appropriate when the label is wider that the ellipse. How do I control the label so that I can choose the width of the label without changing the width of the ellipse?




1 Reply

AA Amsath Ali M Syncfusion Team January 16, 2014 12:42 PM UTC

Hi Jan,

 

Thanks for your interest in syncfusion products.

 

We suggest you to set the Label’s ‘WrapText’ property to false to achieve your requirement. Please refer the below code snippet.

 

Here is the code:

[c#]

Syncfusion.Windows.Forms.Diagram.Label lbl = new Syncfusion.Windows.Forms.Diagram.Label(ellp, "Text in Ellipse");

                lbl.WrapText = false;

                ellp.Labels.Add(lbl);

 

 

Please let us know if you have any queries.

 

Regards,

Amsath Ali. M


Loader.
Live Chat Icon For mobile
Up arrow icon