Hi,
is there an easy way to rotate a lable 90 deg?
thanx
Rotate a lable in c#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Hi,
is there an easy way to rotate a lable 90 deg?
thanx
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
FroglegRank #1,020 · 1.9K reputationPosted Oct 20, 2013, 3:47 PM EDT
public partial class Form1 : Form
{
Font myFont = new Font("Arial", 14);
Brush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
Point pt;
float deg = 90;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pt = new Point(30, 10);
}
private void label1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.TranslateTransform(pt.X, pt.Y);
e.Graphics.RotateTransform(deg);//set rotation
e.Graphics.DrawString("Label1", myFont, myBrush, 0,0);
}
private void rb1_CheckedChanged(object sender, EventArgs e)
{
if (rb1.Checked)
{
pt.X = 30;
pt.Y = 10;
deg = 90;
label1.Refresh();
}
}
private void rb2_CheckedChanged(object sender, EventArgs e)
{
if (rb2.Checked)
{
pt.X = 10;
pt.Y =75;
deg = 270;
label1.Refresh();
}
}
}
Jignesh TrivediRank #16 · 50.3K reputationPosted Oct 20, 2013, 8:57 PM EDT
Hi,
If you asp.net usee than this can be acheive by using CSS
Please refer
http://forums.asp.net/t/1811106.aspx
if you are winform base application user
please refer
http://stackoverflow.com/questions/1371943/c-sharp-vertical-label-in-a-winform
hope this will help you.