Export (0) Print
Expand All

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)

'Declaration
Public Property HasMorePages As Boolean

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.

    ' 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

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

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft