PrintPageEventArgs::HasMorePages Property

 

Gets or sets a value indicating whether an additional page should be printed.

Namespace:   System.Drawing.Printing
Assembly:  System.Drawing (in System.Drawing.dll)

public:
property bool HasMorePages {
	bool get();
	void set(bool value);
}

Property Value

Type: System::Boolean

true if an additional page should be printed; otherwise, false. The default is false.

The following code example assumes a Button named printButton and a PrintDocument named pd have been created on a Form. Make sure the Click event for the Button is associated with the printButton_Click method and the PrintPage event of the PrintDocument is associated with the pd_PrintPage method in the example. The printButton_Click method from the example calls the Print method raising the PrintPage event, and prints the .bmp file specified in the pd_PrintPage method. To run this example, change the path to the bitmap you want to print.

Use the System.Drawing, System.Drawing.Printing, and System.Windows.Forms namespaces for this example.

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;
   }

For another example that shows how to use HasMorePages, see How to: Print a Multi-Page Text File in Windows Forms

.NET Framework
Available since 1.1
Return to top
Show: