Lets users select a printer and choose which sections of the document to print from a Windows Forms application.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Gets or sets a value indicating whether the Current Page option button is displayed.
Gets or sets a value indicating whether the Print to file check box is enabled.
Gets or sets a value indicating whether the Selection option button is enabled.
Gets or sets a value indicating whether the Pages option button is enabled.
Gets or sets the printer settings the dialog box modifies.
Gets or sets a value indicating whether the Print to file check box is selected.
Gets or sets a value indicating whether the Help button is displayed.
Gets or sets a value indicating whether the Network button is displayed.
Gets or sets an object that contains data about the control. (Inherited from CommonDialog.)
Gets or sets a value indicating whether the dialog should be shown in the Windows XP style for systems running Windows XP Home Edition, Windows XP Professional, Windows Server 2003 or later.
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)
Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)
Resets all options, the last selected printer, and the page settings to their default values.(Overrides CommonDialog.Reset().)
Runs a common dialog box with a default owner.(Inherited from CommonDialog.)
Runs a common dialog box with the specified owner.(Inherited from CommonDialog.)
For more information about printing with Windows Forms, see the System.Drawing.Printing namespace overview. If you want to print from a Windows Presentation Foundation application, see the System.Printing namespace.
The following code example demonstrates how to use the AllowSomePages, ShowHelp, and Document properties. To run this example, paste the following code into a form that contains a control named PrintDialog1 and a button named Button1. This example requires that the button's Click event and the PrintPage event of docToPrint have been connected to the event-handling methods defined in this example.control to set the
' Declare the PrintDocument object. Private WithEvents docToPrint As New Printing.PrintDocument ' This method will set properties on the PrintDialog object and ' then display the dialog. Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click ' Allow the user to choose the page range he or she would ' like to print. PrintDialog1.AllowSomePages = True ' Show the help button. PrintDialog1.ShowHelp = True ' Set the Document property to the PrintDocument for ' which the PrintPage Event has been handled. To display the ' dialog, either this property or the PrinterSettings property ' must be set PrintDialog1.Document = docToPrint Dim result As DialogResult = PrintDialog1.ShowDialog() ' If the result is OK then print the document. If (result = DialogResult.OK) Then docToPrint.Print() End If End Sub ' The PrintDialog will print the document ' by handling the document's PrintPage event. Private Sub document_PrintPage(ByVal sender As Object, _ ByVal e As System.Drawing.Printing.PrintPageEventArgs) _ Handles docToPrint.PrintPage ' Insert code to render the page here. ' This code will be called when the control is drawn. ' The following code will render a simple ' message on the printed document. Dim text As String = "In document_PrintPage method." Dim printFont As New System.Drawing.Font _ ("Arial", 35, System.Drawing.FontStyle.Regular) ' Draw the content. e.Graphics.DrawString(text, printFont, _ System.Drawing.Brushes.Black, 10, 10) End Sub
Available since 1.1
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.