PageSettings.PrinterResolution Vlastnost

Definice

Získá nebo nastaví rozlišení tiskárny pro stránku.

public:
 property System::Drawing::Printing::PrinterResolution ^ PrinterResolution { System::Drawing::Printing::PrinterResolution ^ get(); void set(System::Drawing::Printing::PrinterResolution ^ value); };
public System.Drawing.Printing.PrinterResolution PrinterResolution { get; set; }
member this.PrinterResolution : System.Drawing.Printing.PrinterResolution with get, set
Public Property PrinterResolution As PrinterResolution

Hodnota vlastnosti

A PrinterResolution , který určuje rozlišení tiskárny pro stránku. Výchozí je výchozí rozlišení tiskárny.

Výjimky

Tiskárna s názvem ve PrinterName vlastnosti neexistuje nebo není nainstalována výchozí tiskárna.

Příklady

Následující příklad kódu nastaví tři vlastnosti pro výchozí stránku dokumentu, včetně rozlišení tiskárny na základě rozlišení vybraného v comboPrintResolution poli se seznamem, a pak vytiskne dokument pomocí Print metody . Příklad vyžaduje, aby existovala proměnná PrintDocument s názvem printDoc a konkrétní pole se seznamem.

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();
   }
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();
}
Private Sub MyButtonPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyButtonPrint.Click

    ' Set the paper size based upon the selection in the combo box.
    If comboPaperSize.SelectedIndex <> -1 Then
        printDoc.DefaultPageSettings.PaperSize = _
        printDoc.PrinterSettings.PaperSizes.Item(comboPaperSize.SelectedIndex)
    End If

    ' Set the paper source based upon the selection in the combo box.
    If comboPaperSource.SelectedIndex <> -1 Then
        printDoc.DefaultPageSettings.PaperSource = _
        printDoc.PrinterSettings.PaperSources.Item(comboPaperSource.SelectedIndex)
    End If

    ' Set the printer resolution based upon the selection in the combo box.
    If comboPrintResolution.SelectedIndex <> -1 Then
        printDoc.DefaultPageSettings.PrinterResolution = _
        printDoc.PrinterSettings.PrinterResolutions.Item(comboPrintResolution.SelectedIndex)
    End If

    ' Print the document with the specified paper size and source.
    printDoc.Print()

End Sub

Poznámky

Objekt PrinterResolution představuje rozlišení tiskárny prostřednictvím PrinterResolution.Kind vlastnosti , která obsahuje jednu z PrinterResolutionKind hodnot.

PrinterResolution Nastavte vlastnost stránky na platnou PrinterResolutionhodnotu , která je k dispozici prostřednictvím PrinterSettings.PrinterResolutions kolekce.

Platí pro

Viz také