print document

  • Thread starter Thread starter [Yosi]
  • Start date Start date
Y

[Yosi]

I trying to print my App form by printDocument,
i trying to draw the text box, but i don't know how to
draw the the text in the right alignment.

// print edit box control contents
if (Controls.GetType() == this.textBox1.GetType())
{
TextBox theText = (TextBox)Controls;
g.DrawString(theText.Text, theText.Font, Brushes.Black,
theText.Bounds.Left*scalex, theText.Bounds.Top * scaley,
new StringFormat());
}

the result of this is. the text print in left align how
to to make it to be on the right align
 
You want to use


You want to use the DrawString overload that takes a
System.Drawing.StringFormat, and you want to set the StringFormat's
alignment property to Far

Do something like this (Replace the font, brush, text, and rectangle with
your own):

System.Drawing.StringFormat Text3Format = new
System.Drawing.StringFormat(System.Drawing.StringFormat.GenericTypographic);
Text3Format.Alignment = System.Drawing.StringAlignment.Far;
e.Graphics.DrawString(this.Text3, this.Text3Font, this.Text3Brush,
this.Text3Rect, Text3Format);
 
Back
Top