Rotated Label

Hi,

I'm sort of new working with the SyncFusion controls and I found myself looking for some special control (maybe it already existes and I haven's found it yet). I was looking for a Label control (just like the normal one) with a particular property: Angle. Depending on the value given for angle the text for the label is written rotated (as an example I attached something seen in the Grid control).

Does that kind of control already exist? If so, where can I find it?

Thanks in advance



RotatedLabel_de1378cd.zip

4 Replies

MJ Mano J Syncfusion Team October 23, 2009 04:19 AM UTC

Hi Francisco,

We don't have a label with rotating ability. But you can derive a RotatingLabel from Syncfusion's AutoLabel control as shown below

public class RotatingLabel : AutoLabel
{
private int angle = 0;
public RotatingLabel()
{
}

public int Angle
{
get { return angle; }
set
{
angle = value;
this.Invalidate();
}
}

protected override void OnPaint(PaintEventArgs e)
{
if (angle > 0)
{
StringFormat string_format = new StringFormat();
string_format.Alignment = StringAlignment.Center;
string_format.LineAlignment = StringAlignment.Center;
e.Graphics.RotateTransform(angle);
e.Graphics.TranslateTransform(this.ClientSize.Width / 2, this.ClientSize.Height / 2, System.Drawing.Drawing2D.MatrixOrder.Append);
SolidBrush brush = new SolidBrush(this.ForeColor);
e.Graphics.DrawString(this.Text, this.Font, brush, 0, 0, string_format);
}
else
base.OnPaint(e);
}
}

Regards,
Mano


FB FRANCISCO BARREDO October 26, 2009 08:56 AM UTC

Thanks


MJ Mano J Syncfusion Team October 27, 2009 09:40 AM UTC

Hi Francisco,

Thanks for the update.

Regards,
Mano


UR urvish replied to Mano J March 17, 2018 09:48 AM UTC

Hi Francisco,

Thanks for the update.

Regards,
Mano

you can do it by using math calss.

Loader.
Up arrow icon