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 ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.