I wrote a response to someone earlier regarding alignment.
For left align, use PadRight (placing spaces on the right of the text).
For right align, use PadLeft (placing spaces on the left of the text).
E.g
"DATE: 03/05/2006"
PadRight (30):
"DATE: 03/05/2006 "
PadLeft (30):
" DATE: 03/05/2006"
Centering is done by getting the length of the line, the length of the text and finding the start position.
Code:
public static string CentreText(string text, int widthOfLine)
{
int startPosition = (int)Math.Floor(( width_of_line - text.Length ) / 2);
StringBuilder str = new StringBuilder( new string(' ' , widthOfLine) );
str.Insert(text,startPosition);
return str.ToString();
}