PrintPreview issue...

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
My app uses the standard "Print Preview" to display what "PrintDocument1" looks like prior to the actual printing task. In the PrintDocument1.PrintPage event handler, some checks are done to insure that the printed image will actually fit on the page. If the user has set the margins in a manner that would prevent the image from printing correctly, then an error message is displayed after which the following statements are involked:
e.HasMorePages = False
e.Cancel = True
Exit Sub

Now when the user returns to the printer set up process and makes corrections to the bogus margin settings, and goes to print again, the process completely skips PrintDocument1.PrintPage event handler and displays a blank page. The 3rd time the user goes through this process, everything works OK (provided the user has set some realistic margins). I'm thinking the "e.Cancel" or the "e.HasMorePages" statement has flipped the process some how. I don't want to dispose and recreate the PrintPreview class every time the user goes to print because of other overhead involved. I'm wondering if there's a property or method that I've overlooked that would clear or reset the PrintPreview dialog and avoid the confusion this causes the user.
 
Most likely you are not using the BeginPrint and/or EndPrint events properly or at all. BeginPrint allows you to perform some initialisation at the beginning of a print run and End Print allows you to perform some cleanup at the end of a print run. You should look into them and handle them and see how you can use them to fix your problem.
 
Back
Top