Hi all
Got the following to print a richtext box (tbUpperBody)
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)
Dim rect As New Rectangle(75, 150, 680, 1000)
ev.Graphics.DrawString(tbUpperBody.Text, New Font("Courier New", _
14, FontStyle.Regular), Brushes.Black, rect)
ev.Graphics.DrawString(tbScriptName.Text, New Font("Courier New", _
14, FontStyle.Bold), Brushes.Black, 120, 120)
ev.HasMorePages = False
End Sub
'PRINT TOP SCRIPT PART 2
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 when the text that needs printed is more than one page long? it seems i can only get it to print infinite pages or one page, rather than the necessary number of pages...
help appreciated!