Export (0) Print
Expand All

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.

ExceptionCondition
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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft