PageSettings.PrinterResolution Propiedad

Definición

Obtiene o establece la resolución de impresora de la página.Gets or sets the printer resolution for the page.

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

Valor de propiedad

PrinterResolution que especifica la resolución de impresora de la página.A PrinterResolution that specifies the printer resolution for the page. El valor predeterminado es la resolución predeterminada de la impresora.The default is the printer's default resolution.

Excepciones

La impresora que se menciona en la propiedad PrinterName no existe o no se encuentra instalada de forma predeterminada.The printer named in the PrinterName property does not exist or there is no default printer installed.

Ejemplos

En el ejemplo de código siguiente se establecen tres propiedades de la página predeterminada del documento, incluida la resolución de la impresora en función de comboPrintResolution la resolución seleccionada en el cuadro combinado y, a Print continuación, se imprime el documento mediante el método.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. El ejemplo requiere que una PrintDocument variable denominada printDoc exista y que los cuadros combinados específicos existan.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();
   }
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

Comentarios

Representa la resolución de la impresora a través PrinterResolution.Kind de la propiedad, que contiene uno PrinterResolutionKind de los valores de. PrinterResolutionA PrinterResolution represents the printer resolution of through the PrinterResolution.Kind property, which contains one of the PrinterResolutionKind values.

Establezca la PrinterResolution propiedad de la página en un válido PrinterResolution, disponible a través PrinterSettings.PrinterResolutions de la colección.Set the PrinterResolution property for the page to a valid PrinterResolution, available through the PrinterSettings.PrinterResolutions collection.

Se aplica a

Consulte también: