Question Printing using objPrintDoc1 and ev.Graphics.DrawString

J Trahair

Well-known member
Joined
May 14, 2008
Messages
175
Location
Spain
Programming Experience
10+
I am using this method of printing to a printer. Moderate success so far. I need to do 3 things:

1. to get rid of the small blue window that briefly appears showing 'Printing ... Page 1 of document' with a Cancel button.
2. To invoke a printer dialog form, for choosing the printer and the number of pages etc.
3. To find the actual width of the string about to be printed - so I can centre it in the page, or print figures in correctly justified numeric columns.

Code snippet:
HTML:
ev.Graphics.DrawString(mstrPrintData(mnumCurrentItemNumber).ToString, fntPrintFont, Brushes.Black, numLeftMargin + mnumIndentFromLeftMargin(mnumCurrentItemNumber), mnumThisYPosition(mnumCurrentItemNumber), New StringFormat())

In other words, the equivalent to the VB6 Printer.TextWidth(string) thing.

Thanks in advance.
 
1. See JohnH's post - Disabling Printing Status message

2.
VB.NET:
Using pdSelect as new PrintDialog
  pdSelect.ShowDialog
End Using

3. To quote JohnH again, "Use the MeasureString method of Graphics, specify the bounding layoutArea size and utilize the charactersFitted parameter."

Alternatively, setting the alignment and line alignment properties for StringFormat gives you left, centre, right, top, middle and bottom options.
 
Back
Top