Suppose I have an array of 500 strings that I want to print out on multiple pages. I started with the code below, but I just cant figure out how to make it print the first pageful, invoke the .HasMorePages property & then continue printing the next page of items, and so forth, until all the elements in the array are printed. I have tried setting the .HasMorePages property to True when the print location reaches the bottom of the page, but then my loop starts over at the beginning again, giving the same output for all pages.
I know I am close but I just cant figure how to do this. Can anyone help me get this working?
[VB]
Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument2.PrintPage
Dim printFont As New Font("Arial", 12)
Dim lineHeightSingle As Single = printFont.GetHeight + 2
Dim horizontalPrintLocationSingle As Single = e.MarginBounds.Left
Dim verticalPrintLocationSingle As Single = e.MarginBounds.Top
Count pages for multiple-page output.
Static pageCountInteger As Integer = 1
Print the page number.
e.Graphics.DrawString("Page " & pageCountInteger.ToString(), printFont, Brushes.Black, 600, verticalPrintLocationSingle)
verticalPrintLocationSingle = verticalPrintLocationSingle + lineHeightSingle * 2
For xInt As Integer = 1 To 500
Print a line.
e.Graphics.DrawString("This is line " & xInt.ToString, printFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
Double space.
verticalPrintLocationSingle = verticalPrintLocationSingle + lineHeightSingle * 2
Next
End Sub
[/VB]
Thanks for your help...
I know I am close but I just cant figure how to do this. Can anyone help me get this working?
[VB]
Private Sub PrintDocument2_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument2.PrintPage
Dim printFont As New Font("Arial", 12)
Dim lineHeightSingle As Single = printFont.GetHeight + 2
Dim horizontalPrintLocationSingle As Single = e.MarginBounds.Left
Dim verticalPrintLocationSingle As Single = e.MarginBounds.Top
Count pages for multiple-page output.
Static pageCountInteger As Integer = 1
Print the page number.
e.Graphics.DrawString("Page " & pageCountInteger.ToString(), printFont, Brushes.Black, 600, verticalPrintLocationSingle)
verticalPrintLocationSingle = verticalPrintLocationSingle + lineHeightSingle * 2
For xInt As Integer = 1 To 500
Print a line.
e.Graphics.DrawString("This is line " & xInt.ToString, printFont, Brushes.Black, horizontalPrintLocationSingle, verticalPrintLocationSingle)
Double space.
verticalPrintLocationSingle = verticalPrintLocationSingle + lineHeightSingle * 2
Next
End Sub
[/VB]
Thanks for your help...