Print Preview

If you have already written code to support printing, then supporting Print Preview is quite simple. Supporting Print Preview involves using the System.Windows.Forms.PrintPreviewDialog class. This class has a Document property that needs to reference the PrintDocument object that is used during the printing process. The PrintPreviewDialog class takes care of everything else for you. All you need to do is show the dialog using the ShowDialog method.

To update the previous example to include Print Preview, a menu item must be created. Here is the updated CreateMenus method that adds the Print Preview menu item:

 Protected Sub CreateMenus() Dim mnuFile As MenuItem Dim mnuItem As MenuItem ' create main menu m_menu = New MainMenu() ' ...

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.