PageSettings.PrinterResolution Property

Definition

Gets or sets the printer resolution for the page.

C#
public System.Drawing.Printing.PrinterResolution PrinterResolution { get; set; }

Property Value

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

Exceptions

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

Examples

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.

C#
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();
}

Remarks

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.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also