PageSettings.PrinterResolution Property

 

Gets or sets the printer resolution for the page.

Namespace:   System.Drawing.Printing
Assembly:  System.Drawing (in System.Drawing.dll)

public PrinterResolution PrinterResolution { get; set; }

Property Value

Type: System.Drawing.Printing.PrinterResolution

A PrinterResolution that specifies the printer resolution for the page. The default is the printer's default resolution.

Exception Condition
InvalidPrinterException

The printer named in the PrinterSettings.PrinterName property does not exist or there is no default printer installed.

A PrinterResolution represents the printer resolution of through the PrinterResolution.Kind property, which contains one of the PrinterResolutionKind values.

Set the PrinterResolution property for the page to a valid PrinterResolution, available through the PrinterSettings.PrinterResolutions collection.

The following code example sets three properties for the document's default page, including the printer's resolution based upon the resolution selected in the comboPrintResolution combo box, and then prints the document using the Print method. The example requires that a PrintDocument variable named printDoc exists and that the specific combo boxes exist.

private void MyButtonPrint_Click(object sender, System.EventArgs e)
{
    // Set the paper size based upon the selection in the combo box.
    if (comboPaperSize.SelectedIndex != -1) {
        printDoc.DefaultPageSettings.PaperSize = 
            printDoc.PrinterSettings.PaperSizes[comboPaperSize.SelectedIndex];
    }

    // Set the paper source based upon the selection in the combo box.
    if (comboPaperSource.SelectedIndex != -1) {
        printDoc.DefaultPageSettings.PaperSource = 
            printDoc.PrinterSettings.PaperSources[comboPaperSource.SelectedIndex];
    }

    // Set the printer resolution based upon the selection in the combo box.
    if (comboPrintResolution.SelectedIndex != -1) 
    {
        printDoc.DefaultPageSettings.PrinterResolution= 
            printDoc.PrinterSettings.PrinterResolutions[comboPrintResolution.SelectedIndex];
    }

    // Print the document with the specified paper size, source, and print resolution.
    printDoc.Print();
}

.NET Framework
Available since 1.1
Return to top
Show: