Printing Changes in Visual Basic .NET
Visual Basic .NET provides greatly improved support for printing through classes that control the printing of documents, that allow users to modify print settings and choose printers, and that allow print preview.
Printer Object Changes
In Visual Basic 6.0, the Printer object was used for printing; it supported various graphics methods such as Print, Line, and PaintPicture to control what was printed.
In Visual Basic .NET, the PrintDocument component replaces the Printer object. Equivalent graphics methods include the DrawString, DrawLine, and DrawImage methods of the Graphics class.
For details, see Printer Object Changes in Visual Basic .NET.
Printers Collection Changes
In Visual Basic 6.0, the Printers collection was used to direct the output of a Printer object to a different printer. The Printers collection contained a list of available printers that matched the list displayed in the Windows Print dialog box.
In Visual Basic .NET, the Printers collection is replaced by the PrintDialog control, which provides a standard Windows Print dialog box.
For details, see Printers Collection Changes in Visual Basic .NET.
Other Printing Changes
In Visual Basic 6.0, the PrintForm method of a form could be used to send an image of the form to a printer. The PrintForm method is no longer supported in Visual Basic .NET. The results of the PrintForm method varied greatly depending on the screen resolution and the resolution of the printer; it was not the recommended method of printing. If you need to duplicate the functionality of the PrintForm method, you can automate the screen capture capabilities of a third-party graphics tool to capture and print an image of a form.
In Visual Basic 6.0, implementing print preview was only possible through third-party controls. In Visual Basic .NET, the PrintPreviewDialog control can be used to provide a standard Windows Print Preview dialog box. For more information, see Introduction to the Windows Forms PrintPreviewDialog Control.
In Visual Basic 6.0, no user interface for page setup was provided. In Visual Basic .NET, the PageSetupDialog control can be used to provide a standard Windows Page Setup dialog box. For more information, see Introduction to the Windows Forms PageSetupDialog Component.
In Visual Basic 6.0, printing text from a file required a considerable amount of code. In Visual Basic .NET, the StreamReader class can be used to pass the contents of a text file directly to a PrintDocument component. For details, see PrintDocument.Print Method.