PrintPageEventArgs.HasMorePages Vlastnost

Definice

Získá nebo nastaví hodnotu určující, zda má být vytištěna další stránka.

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

Hodnota vlastnosti

truepokud by měla být vytištěna další stránka; v opačném případě . false Výchozí formát je false.

Příklady

Následující příklad kódu předpokládá, že na objektu PrintDocument byly vytvořeny pojmenované printButton a pojmenovanéFormpd.Button Ujistěte se, Click že je událost pro Button parametr přidružená k printButton_Click metodě a PrintPage že je událost PrintDocument přidružená k pd_PrintPage metodě v příkladu. Metoda printButton_Click z příkladu volá metodu Print vyvolání PrintPage události a vytiskne .bmp soubor zadaný v pd_PrintPage metodě. Chcete-li spustit tento příklad, změňte cestu na rastrový obrázek, který chcete vytisknout.

V tomto příkladu System.Drawingpoužijte obory názvů , System.Drawing.Printinga System.Windows.Forms .

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

Další příklad, který ukazuje, jak používat HasMorePages, najdete v tématu Postupy: Tisk vícestránkového textového souboru v model Windows Forms.

Platí pro

Viz také