Mega Code Archive

 
Categories / C# / 2D Graphics
 

StringAlignment Near

using System; using System.Drawing; using System.Windows.Forms;     class FourCorners: Form {      public static void Main()      {           Application.Run(new FourCorners());      }      public FourCorners()      {           Text = "Four Corners Text Alignment";           BackColor = SystemColors.Window;           ForeColor = SystemColors.WindowText;           ResizeRedraw = true;      }      protected override void OnPaint(PaintEventArgs pea)      {           Graphics     graphics   = pea.Graphics;           Brush        brush  = new SolidBrush(ForeColor);           StringFormat strfmt = new StringFormat();               strfmt.Alignment     = StringAlignment.Near;           strfmt.LineAlignment = StringAlignment.Near;           graphics.DrawString("Upper left corner", Font, brush, 0, 0, strfmt);          } }