Question: PrintDocument_PrintPage - only does what's visible

  • Thread starter Thread starter VB Programmer
  • Start date Start date
V

VB Programmer

I have a multiline text box with a scroll bar. I want to print out the
ENTIRE contents of the text box, but it's only printing what's visible.

Here's my PrintPage code:

Private Sub PrintDocument_PrintPage(ByVal sender As System.Object, ByVal
e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument.PrintPage
Try
e.Graphics.DrawString(txtDisplay.Text, New
Font(txtDisplay.Font.Name, txtDisplay.Font.Size,
FontStyle.Regular),Brushes.Black, 150, 125)
Catch ex As Exception
HandleError(ex, "PrintDocument_PrintPage")
End Try
End Sub

Any ideas how to do this?
 
Hi,

The version of drawstring you are using will print on only one line.
If you use a drawstring that takes a rectanglef it will word wrap for you.

g.DrawString(textbox1.text, textbox1.font, Brushes.Black,
RectangleF.op_Implicit(e.PageBounds))


Ken
 
Thanks. That works better, but, it still only prints page 1. I assume I
have to use the HasMorePages property. Can someone post a link or simple
example? There can be 2-4 pages.
 
Back
Top