Solved

PrintPreviewDialog1.ShowDialog() unhandled exception

Posted on 2006-06-14
1
393 Views
Last Modified: 2008-02-01
I have a private function in my program called OnPrintPage, this adds images using e.Graphics.DrawImage(MyImage, x, y) to the printing area. X and y are incremented in OnPrintPage so as to add a selection of images for printing. The entire function OnPrintPage completes without exceptions, however when a call to ShowDialog on a PrintPreviewDialog is made an unhandled exception occurs. THis only happens when the images fall outside the first page. With a couple of images, it works fine. With more images than there is available space for y I get this error.

What should I do to print onto multiple pages??
0
Comment
Question by:craigdev
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 16900769
Printing is done in the PrintDocument PrintPage event handler. This function has PrintPageEventArgs e parameter. This function must print only current page, and call:
e.HasMorePages = false
to stop printing, or
e.HasMorePages = true
to continue printing. If HasMorePages is set to true, PrintPage function is called again and prints next page.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now