PrintPageEventArgs.HasMorePages Propiedad

Definición

Obtiene o establece un valor que indica si se debe imprimir una página adicional.

public:
 property bool HasMorePages { bool get(); void set(bool value); };
public bool HasMorePages { get; set; }
member this.HasMorePages : bool with get, set
Public Property HasMorePages As Boolean

Valor de propiedad

truesi se debe imprimir; en caso contrario, false. De manera predeterminada, es false.

Ejemplos

En el ejemplo de código siguiente se supone que se ha creado un Button denominado printButton y un PrintDocument con nombre pd en .Form Asegúrese de que el Click evento de Button está asociado al printButton_Click método y el PrintPage evento de PrintDocument está asociado al pd_PrintPage método en el ejemplo. El printButton_Click método del ejemplo llama al Print método que genera el PrintPage evento e imprime el archivo .bmp especificado en el pd_PrintPage método . Para ejecutar este ejemplo, cambie la ruta de acceso al mapa de bits que desea imprimir.

Use los System.Drawingespacios de nombres , System.Drawing.Printingy System.Windows.Forms para este ejemplo.

private:
   // Specifies what happens when the user clicks the Button.
   void printButton_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      try
      {
         pd->Print();
      }
      catch ( Exception^ ex ) 
      {
         MessageBox::Show( "An error occurred while printing", ex->ToString() );
      }
   }

   // Specifies what happens when the PrintPage event is raised.
   void pd_PrintPage( Object^ /*sender*/, PrintPageEventArgs^ ev )
   {
      // Draw a picture.
      ev->Graphics->DrawImage( Image::FromFile( "C:\\My Folder\\MyFile.bmp" ),
         ev->Graphics->VisibleClipBounds );
      
      // Indicate that this is the last page to print.
      ev->HasMorePages = false;
   }

// Specifies what happens when the user clicks the Button.
 private void printButton_Click(object sender, EventArgs e) 
 {
   try 
   {
     // Assumes the default printer.
     pd.Print();
   }  
   catch(Exception ex) 
   {
     MessageBox.Show("An error occurred while printing", ex.ToString());
   }
 }
 
 // Specifies what happens when the PrintPage event is raised.
 private void pd_PrintPage(object sender, PrintPageEventArgs ev) 
 {      
   // Draw a picture.
   ev.Graphics.DrawImage(Image.FromFile("C:\\My Folder\\MyFile.bmp"), ev.Graphics.VisibleClipBounds);
      
   // Indicate that this is the last page to print.
   ev.HasMorePages = false;
 }
' Specifies what happens when the user clicks the Button.
Private Sub printButton_Click(sender As Object, e As EventArgs) _
Handles printButton.Click
    Try
       pd.Print()
    Catch ex As Exception
        MessageBox.Show("An error occurred while printing", _
            ex.ToString())
    End Try
End Sub    

' Specifies what happens when the PrintPage event is raised.
Private Sub pd_PrintPage(sender As Object, ev As PrintPageEventArgs) _
Handles pd.PrintPage

    ' Draw a picture.
    ev.Graphics.DrawImage(Image.FromFile("C:\My Folder\MyFile.bmp"), _
        ev.Graphics.VisibleClipBounds)
    
    ' Indicate that this is the last page to print.
    ev.HasMorePages = False
End Sub

Para obtener otro ejemplo que muestra cómo usar HasMorePages, vea Cómo: Imprimir un archivo de texto de varias páginas en Windows Forms.

Se aplica a

Consulte también