QueryPageSettingsEventArgs Class
Provides data for the QueryPageSettings event.
Assembly: System.Drawing (in System.Drawing.dll)
It is possible to print each page of a document using different page settings. You set page settings by modifying individual properties of the PageSettings property or by setting the property to a PageSettings. The print job can also be canceled by setting the Cancel property to true.
The following code example prints a document with the first page in color, if the printer supports it. The example assumes that a PrintDocument variable named printDoc has been created, and the PrintPage and QueryPageSettings events are handled.
Use the System.Drawing and System.Drawing.Printing namespaces for this example.
Private Sub MyButtonPrint_OnClick(ByVal sender As Object, ByVal e As System.EventArgs) ' Set the printer name and ensure it is valid. If not, provide a message to the user. printDoc.PrinterSettings.PrinterName = "\\mynetworkprinter" If printDoc.PrinterSettings.IsValid Then ' If the printer supports printing in color, then override the printer's default behavior. if printDoc.PrinterSettings.SupportsColor then ' Set the page default's to not print in color. printDoc.DefaultPageSettings.Color = False End If ' Provide a friendly name, set the page number, and print the document. printDoc.DocumentName = "My Presentation" currentPageNumber = 1 printDoc.Print() Else MessageBox.Show("Printer is not valid") End If End Sub Private Sub MyPrintQueryPageSettingsEvent(ByVal sender As Object, ByVal e As QueryPageSettingsEventArgs) ' Determines if the printer supports printing in color. If printDoc.PrinterSettings.SupportsColor Then ' If the printer supports color printing, use color. If currentPageNumber = 1 Then e.PageSettings.Color = True End If End If End Sub
System.EventArgs
System.ComponentModel.CancelEventArgs
System.Drawing.Printing.PrintEventArgs
System.Drawing.Printing.QueryPageSettingsEventArgs
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.