StringAlignment.Near : StringAlignment « 2D Graphics « C# / C Sharp






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);
   
     }
}

 








Related examples in the same category

1.Enuermate the StringAlignment value
2.String Alignment (PointF in DrawString)
3.StringAlignment.Center
4.StringAlignment.Far