StringAlignment.Center : StringAlignment : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » StringAlignment »

 

StringAlignment.Center








    
 


using System;
using System.Drawing;
using System.Windows.Forms;
   
class HelloCenteredRectangle: Form
{
     public static void Main() 
     {
          Application.Run(new HelloCenteredRectangle()); 
     }
     public HelloCenteredRectangle()
     {
          Text = "Hello Centered Using Rectangle";
          BackColor = SystemColors.Window;
          ForeColor = SystemColors.WindowText;
          ResizeRedraw = true;
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics     grfx   = pea.Graphics;
          StringFormat strfmt = new StringFormat();
   
          strfmt.Alignment     = StringAlignment.Center;
          strfmt.LineAlignment = StringAlignment.Center;
   
          grfx.DrawString("Hello, world!", Font, new SolidBrush(ForeColor),
                          ClientRectangle, strfmt);
     }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» StringAlignment