PageSettings.PrinterResolution Propriedade

Definição

Obtém ou define a resolução da impressora para a página.

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 da propriedade

Um PrinterResolution que especifica a resolução da impressora para a página. O padrão é a resolução padrão da impressora.

Exceções

A impressora nomeada na propriedade PrinterName não existe ou não há nenhuma impressora padrão instalada.

Exemplos

O exemplo de código a seguir define três propriedades para a página padrão do documento, incluindo a resolução da impressora com base na resolução selecionada na caixa de combinação e, em comboPrintResolution seguida, imprime o documento usando o Print método . O exemplo requer que exista uma PrintDocument variável chamada printDoc e que existam as caixas de combinação específicas.

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

Comentários

Um PrinterResolution representa a resolução da impressora por meio da PrinterResolution.Kind propriedade , que contém um dos PrinterResolutionKind valores.

Defina a PrinterResolution propriedade da página como válida PrinterResolution, disponível por meio da PrinterSettings.PrinterResolutions coleção.

Aplica-se a

Confira também