Rotate the string

Description :


We can rotate the text by giving angel.
We can rotate the text simply override the onPaint event
The Following is the code for rotating the text.

protected override void OnPaint(PaintEventArgs e)
{
Graphics MyGraphics = e.Graphics;
MyGraphics.FillRectangle(Brushes.White, this.ClientRectangle);
Font MyFont = new Font("Times New Roman", 24);
MyGraphics.DrawString("The Text for rotate", MyFont, Brushes.Black, 0, 0);
MyGraphics.RotateTransform(45);
MyGraphics.TranslateTransform(150, 0);
MyGraphics.DrawString("The Text for rotate", MyFont, Brushes.Black, 0, 0);
}


Code Explanation

1. Create the instance of the Graphics
2. Fill it with rectangle
3. Create the instance of the Font
4. Write the text in the instance of the Graphics
5. Rotate the string by giving the angle.
6. Draw the string again

By
Nathan


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: