Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to print a List View, there are too many lines in the ListView so I want to print more pages for all the items, how do I do this?

What I have tried:

e.HasMorePages but this prints over the existing page, it does not print to a new sheet of paper.
Posted
Updated 25-Nov-18 20:19pm

1 solution

If you are using e.HasMorePages then you are - correctly - using a PrintDocument.

e.HasMorePages tells the system that after you return from the PrintPage event handler, it should finish passing the page to the output and then raise a new PrintPage event to let you put the next set of information together.
From the sound of it, you are setting HasMorePages in a loop and expecting that to end the page out put - that doesn't happen: you need to exit the event handler to finalise the page.

Try this very basic example:
VB
Private pageNo As Integer = 1

Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
    ev.Graphics.DrawString(pageNo.ToString(), Font, Brushes.Black, 100, 100)
    pageNo = pageNo + 1
    ev.HasMorePages = pageNo <= 3
End Sub
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900