O'Reilly logo

Visual Basic® .NET by Example by Bob Donald, Gabriel Oancea

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

Creating a Custom PrintDocument Class

If you dragged and dropped a PrintDocument control from the Toolbox onto a form (in Design mode), you would end up with an additional data member added to the form, and the data member's datatype would be PrintDocument. Then, to handle the events, you would create event handlers for the PrintDocument data member the same way as it was done earlier in this chapter.

Although this works for the purposes of quickly developing a form, there are a couple of problems doing it this way. The resulting code, which performs the actual printing, is part of the Form class itself. This means the code for the form handles the display of the form on the screen and also the printing of the form's data. It seems it would be ...

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