3
Answers

Lable Rotation in C# Windows alication

Photo of Talib Ahmad

Talib Ahmad

7y
143
1
How to Rotate the Lable by 180 degreee in windos aplication with auto size true

Answers (3)

1
Photo of Rajkiran Swain
NA 33.9k 373.6k 7y
https://stackoverflow.com/questions/1371943/c-sharp-vertical-label-in-a-windows-forms
0
Photo of Laxmidhar Sahoo
NA 2.3k 1.4k 7y
Rajkiran is the currect .One change there and the code may help you
 
  1. private void button1_Click(object sender, EventArgs e)  
  2.        {  
  3.            GenerateTexture();  
  4.        }  
  5.        private void GenerateTexture()  
  6.        {  
  7.            StringFormat format = new StringFormat();  
  8.            format.Alignment = StringAlignment.Center;  
  9.            format.LineAlignment = StringAlignment.Center;  
  10.            format.Trimming = StringTrimming.EllipsisCharacter;  
  11.   
  12.            Bitmap img = new Bitmap(this.Height, this.Width);  
  13.            Graphics G = Graphics.FromImage(img);  
  14.   
  15.            G.Clear(this.BackColor);  
  16.   
  17.            SolidBrush brush_text = new SolidBrush(this.ForeColor);  
  18.            G.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;  
  19.            G.DrawString(label1.Text, this.Font, brush_text, new Rectangle(0, 0, img.Width, img.Height), format);  
  20.            brush_text.Dispose();  
  21.   
  22.            img.RotateFlip(RotateFlipType.Rotate270FlipNone);  
  23.   
  24.            this.BackgroundImage = img;  
  25.        }  
 
 
 
0
Photo of Sagar  Pandurang Kap
NA 2.7k 7.6k 7y
HI,
Refer below link :-
It is for 90 degrees.So make changes as 180 degrees.
 
http://www.c-sharpcorner.com/forums/rotate-a-lable-in-c-sharp
 
Hope it helps..