kh_mneimneh
Member
- Joined
- Feb 27, 2006
- Messages
- 7
- Programming Experience
- Beginner
Hi every one
I am a newbie to vb.net.
I am experimenting with printing example.
I want to print 2 colums, on 2 pages, one on every page. I managed to get a second page, but my problem is that all the printing takes place only on the first page, and the second page appears blank.
can anybody help me please. Thanks in advance.
here is my test code
Protected Sub ThePrintDocument_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs) Handles ThePrintDocument.PrintPage
Dim linesPerPage As Single = 0
Static yPosition As Single = 25
Static count As Integer = 0
Dim leftMargin As Single = ev.MarginBounds.Left
Dim topMargin As Single = ev.MarginBounds.Top
Dim bottomMargin As Single = ev.MarginBounds.Bottom
Dim line As String = Nothing
Dim printFont As Font = Me.richTextBox1.Font
Dim myBrush As New SolidBrush(Color.Black)
' Work out the number of lines per page, using the MarginBounds.
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
linesPerPage = 20
While count < linesPerPage
Dim j As Integer
For j = 0 To 40
' calculate the next line position based on
' the height of the font according to the printing device
'If count = linesPerPage Then
'yPosition = 25 '+ (printFont.GetHeight(ev.Graphics))
'Else
yPosition = yPosition + (printFont.GetHeight(ev.Graphics))
'End If
' draw the next line in the rich edit control
ev.Graphics.DrawString("Hello", printFont, myBrush, leftMargin, yPosition, New StringFormat())
count += 1
If count > linesPerPage Then
ev.HasMorePages = True
leftMargin = 200
'yPosition = 25
Else
ev.HasMorePages = False
End If
Next j
End While
myBrush.Dispose()
End Sub 'ThePrintDocument_PrintPage
I am a newbie to vb.net.
I am experimenting with printing example.
I want to print 2 colums, on 2 pages, one on every page. I managed to get a second page, but my problem is that all the printing takes place only on the first page, and the second page appears blank.
can anybody help me please. Thanks in advance.
here is my test code
Protected Sub ThePrintDocument_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs) Handles ThePrintDocument.PrintPage
Dim linesPerPage As Single = 0
Static yPosition As Single = 25
Static count As Integer = 0
Dim leftMargin As Single = ev.MarginBounds.Left
Dim topMargin As Single = ev.MarginBounds.Top
Dim bottomMargin As Single = ev.MarginBounds.Bottom
Dim line As String = Nothing
Dim printFont As Font = Me.richTextBox1.Font
Dim myBrush As New SolidBrush(Color.Black)
' Work out the number of lines per page, using the MarginBounds.
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
linesPerPage = 20
While count < linesPerPage
Dim j As Integer
For j = 0 To 40
' calculate the next line position based on
' the height of the font according to the printing device
'If count = linesPerPage Then
'yPosition = 25 '+ (printFont.GetHeight(ev.Graphics))
'Else
yPosition = yPosition + (printFont.GetHeight(ev.Graphics))
'End If
' draw the next line in the rich edit control
ev.Graphics.DrawString("Hello", printFont, myBrush, leftMargin, yPosition, New StringFormat())
count += 1
If count > linesPerPage Then
ev.HasMorePages = True
leftMargin = 200
'yPosition = 25
Else
ev.HasMorePages = False
End If
Next j
End While
myBrush.Dispose()
End Sub 'ThePrintDocument_PrintPage