Click to Rate and Give Feedback

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Windows Forms Programming
PrintDocument Component Overview (Windows Forms)

The Windows Forms PrintDocument component is used to set the properties that describe what to print and the ability to print the document within Windows-based applications. It can be used in conjunction with the PrintDialog component to be in control of all aspects of document printing.

Two of the main scenarios that involve the PrintDocument component are:

  • Simple print jobs, such as printing an individual text file. In such a case you would add the PrintDocument component to a Windows Form, then add programming logic that prints a file in the PrintPage event handler. The programming logic should culminate with the Print method to print the document. This method sends a Graphics object, contained in the Graphics property of the PrintPageEventArgs class, to the printer. For an example that shows how to print a text document using the PrintDocument component, see How to: Print a Multi-Page Text File in Windows Forms.

  • More complex print jobs, such as a situation where you will want to reuse printing logic you have written. In such a case you would derive a new component from the PrintDocument component and override (see Overrides for Visual Basic or override for C#) the PrintPage event.

When it is added to a form, the PrintDocument component appears in the tray at the bottom of the Windows Forms Designer.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker