Hi, I am really struggling over HasdMorePages in the PrintDocument control. What I need to do is print invoices for our customers. In VB6 I would set the printer and loop through the records. I manually determined if I needed a page break because I knew how many line items could fit on a page. If it did, I called another sub, which added header info like address, column headings, and lines. In case it mattered, it is a Pervasive DB.
I am now trying to print with VB 2005. I can get it to print by using the printDoc_PrintPage sub, but I don't know where I should be looping through my records and how to use the HasMorePages.
I have searched on the Internet for about 4 hours now and have tried coutless tests without doing it correctly.
I have included a test loop just as an example to try to get multiple pages to work. The PrintWorkWrap is a module level sub that automatically wraps the text.
I am now trying to print with VB 2005. I can get it to print by using the printDoc_PrintPage sub, but I don't know where I should be looping through my records and how to use the HasMorePages.
I have searched on the Internet for about 4 hours now and have tried coutless tests without doing it correctly.
I have included a test loop just as an example to try to get multiple pages to work. The PrintWorkWrap is a module level sub that automatically wraps the text.
Code:
Private Sub printDoc_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles printDoc.PrintPage
Dim BCL As New BC.Library
Dim currFont As Drawing.Font
Dim i As Int16
currFont = New Drawing.Font("Arial", 10, Drawing.FontStyle.Regular)
For i = 0 To 3
BCL.PrintWordWrap(e, currFont, 50, 50, 200, "1For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.")
BCL.PrintWordWrap(e, currFont, 75, 550, 200, "2For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.")
If i < 3 Then
e.HasMorePages = True
'Exit For
Else
e.HasMorePages = False
End If
Next i
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim POC As New BC.PrintOptionsClass
Dim printDoc As New PrintDocument
AddHandler printDoc.PrintPage, AddressOf printDoc_PrintPage
POC.GetOptions(printDoc)
printDoc.Print()
End Sub