O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Print a Document That Has Multiple Pages

Problem

You want to print complex documents with multiple pages and possibly print several different documents at once.

Solution

Place the information you want to print into a custom class that derives from PrintDocument, and set the PrintPageEventArgs.HasMorePages property to True as long as there are pages remaining.

Discussion

The PrintDocument.PrintPage event allows you to print only a single page. If you need to print more pages, you need to set the PrintPageEventArgs.HasMorePages property to True in the PrintPage event handler. As long as HasMorePages is True, the PrintDocument class will continue firing PrintPage events, one for each page. However, it’s up to you to track what page you are on, what data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required