[RESOLVED] Print Rich Text Box
Hello
Using the following code to print the contents of my rich textbox
Code:
Private Sub PrintText(ByVal sender As Object, _
ByVal ev As PrintPageEventArgs)
tbUpperBody.Text = vbNewLine &
vbNewLine &
tbUpperBody.Text
Dim blackPen As New Pen(Color.Black, 3)
' Create points that define line.
Dim point1 As New Point(75, 150)
Dim point2 As New Point(725, 150)
' Draw line to screen.
ev.Graphics.DrawLine(blackPen, point1, point2)
ev.Graphics.DrawString(tbUpperBody.Text, New Font("Arial", _
14, FontStyle.Regular), Brushes.Black, 120, 120)
ev.HasMorePages = False
End Sub
Private Sub PrintTopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintTopToolStripMenuItem.Click
Try
Dim PrintDoc As New PrintDocument
AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
PrintDoc.Print()
tbUpperBody.Multiline = True
Catch ex As Exception
MessageBox.Show("Sorry - there was a problem with printing", ex.ToString())
End Try
End Sub
Issue is that when the rich textbox contains text that is spread over multiple lines, it prints as one massive line, which obviously disappears off the edge of the page.
how can i get it to print with line breaks?
thanks