.NET Samples - Windows Forms: Printing

This section includes the following samples:

Simple Printing Example3 Sample

Simple Printing Example2 Sample

Simple Printing Example1 Sample

Simple Printing Example4 Sample

Simple Printing Example5 Sample

SimplePad Sample

Simple Printing Example3 Sample

This sample demonstrates the use of the PrintDialog control to allow the user the option of selecting a printer.

Namespaces used in this sample:

System; System.Drawing; System.Windows.Forms; System.ComponentModel; System.Drawing.Printing; System.IO

Classes used in this sample:

Button; Form; Component; Message; Container; StreamReader; PrintDialog; File; Style; PrintDocument; Stream; Exception; MessageBox; Icon; Image; EventHandler; Application; Thread; EventArgs; Control

Simple Printing Example2 Sample

This sample demonstrates methods for overriding the default PrintDocument for complex print jobs or when a certain printing functionality needs to be reused across multiple forms.

Namespaces used in this sample:

System; System.Drawing; System.Windows.Forms; System.ComponentModel; System.Drawing.Printing; System.IO

Classes used in this sample:

Button; Form; Component; Stream; Message; Container; StreamReader; Style; File; PrintDocument; Exception; MessageBox; Icon; Image; Application; Thread; EventArgs; EventHandler; Control

Simple Printing Example1 Sample

This sample demonstrates the logic needed to enable printing in an application. This includes discussion of the PrintDocument and the various events that must be handled by the application.

Namespaces used in this sample:

System; System.Drawing; System.Windows.Forms; System.ComponentModel; System.Drawing.Printing; System.IO

Classes used in this sample:

Button; Form; Font; Page; Component; String; Graphics; Message; EventHandler; Container; StreamReader; Style; PrintDocument; EventArgs; Stream; StringFormat; Exception; MessageBox; Icon; PrintPageEventArgs; Thread; PrintPageEventHandler; Application; Image; Brush; Brushes; Control

Simple Printing Example4 Sample

This sample demonstrates the use of a PageSettings object and the PageSetupDialog control to allow the user to select various print options.

Namespaces used in this sample:

System; System.Drawing; System.Windows.Forms; System.ComponentModel; System.Drawing.Printing; System.IO

Classes used in this sample:

Button; Form; Page; PageSettings; Component; Style; Message; Exception; MessageBox; PrintDialog; Image; PrintDocument; EventArgs; Stream; PageSetupDialog; EventHandler; Container; StreamReader; File; Control; Application; Icon; Thread

Simple Printing Example5 Sample

This sample demonstrates the use of a PrintPreview control that allows the user to see the printed form of a document before printing.

Namespaces used in this sample:

System; System.Drawing; System.Windows.Forms; System.ComponentModel; System.Drawing.Printing; System.IO

Classes used in this sample:

Button; Page; Form; PageSettings; PrintDocument; Font; File; Component; StreamReader; Message; Stream; Style; EventArgs; Image; Control; Exception; MessageBox; String; EventHandler; Graphics; PageSetupDialog; Container; PrintPreviewDialog; PrintDialog; PrintEventArgs; StringFormat; Icon; Thread; Brushes; Application; Brush; PrintPageEventArgs

SimplePad Sample

This sample demonstrates a Notepad-style application that uses all the printing features provided by Windows Forms.

Namespaces used in this sample:

System; System.Windows.Forms; System.Drawing; System.ComponentModel; System.IO; System.Collections; System.Drawing.Printing

Classes used in this sample:

Menu; Form; MenuItem; File; Page; EventArgs; Font; Button; EventHandler; FileDialog; Component; Panel; Style; PageSettings; Message; String; MessageBox; StatusBar; Stream; Control; TextBox; PrintDocument; StatusBarPanel; Container; RichTextBox; Object; StringReader; FileInfo; Type; Icon; DataObject; Graphics; FileStream; PrintDialog; DataFormats; PropertyGrid; Clipboard; Convert; Exception; FileSystemWatcher; PageSetupDialog; SaveFileDialog; OpenFileDialog; Margins; MainMenu; FontDialog; StringFormat; Directory; PrintPreviewDialog; Application; PrintPageEventArgs; Path; Thread; CancelEventArgs; FileSystemEventArgs; PrintEventArgs; Brush; TypeConverter; Help; Brushes; Array; FileSystemEventHandler; Console; TypeConverterAttribute; OpacityConverter; SystemColors; Attribute