Advertisement
Guest User

WinForms Example

a guest
Jan 13th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5.  
  6. namespace WinFormsExample
  7. {
  8.     public partial class MyForm : Form
  9.     {
  10.         public MyForm()
  11.         {
  12.             this.InitializeComponent();
  13.         }
  14.  
  15.         public void DrawVerticalString()
  16.         {
  17.             Graphics formGraphics = this.CreateGraphics();
  18.             string drawString = this.Name; /* SET THE NAME HERE */
  19.  
  20.             Font drawFont = new Font("Arial", 16);
  21.             SolidBrush drawBrush = new SolidBrush(System.Drawing.Color.Black);
  22.  
  23.             float x = 150.0F;
  24.             float y = 50.0F;
  25.            
  26.             StringFormat drawFormat = new StringFormat();
  27.             drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
  28.             formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
  29.  
  30.             drawFont.Dispose();
  31.             drawBrush.Dispose();
  32.             formGraphics.Dispose();
  33.         }
  34.  
  35.         protected override void OnPaint(PaintEventArgs e)
  36.         {
  37.             this.DrawVerticalString();
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement