Version

PagePrinted Event

Fired after the page is rendered
Syntax
'Declaration
 
Public Event PagePrinted As PagePrintedEventHandler
public event PagePrintedEventHandler PagePrinted
Event Data

The event handler receives an argument of type PagePrintedEventArgs containing data related to this event. The following PagePrintedEventArgs properties provide information specific to this event.

PropertyDescription
Cancel Returns or sets whether the print operation should be cancelled.
Document Returns the document that is being rendered.
FooterRect Returns the area of the page containing the footer.
Graphics Returns the graphics object into which the page should be rendered
HasMorePages Returns or sets whether there are more pages to print.
HeaderRect Returns the area of the page containing the header.
PageBodyRect Returns the area of the page containing the page body.
PageSettings Returns the System.Drawing.Printing.PageSettings associated with the current page being printed.
ReprintPage Returns or sets whether the current page should be reprinted.
Example
The following example demonstrates how to use the PageBodyPrinting and PagePrinted events to insert pages into the print operation.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.Printing

    Private Sub UltraSchedulePrintDocument1_PageBodyPrinting(ByVal sender As Object, ByVal e As Infragistics.Win.Printing.PageBodyPrintingEventArgs) Handles UltraSchedulePrintDocument1.PageBodyPrinting
        ' when the first page is printed, prevent the regular
        ' page body from being printed
        If CType(sender, UltraPrintDocument).PageNumber = 1 Then
            'mark the event as handled so page body of the print document will
            'not be rendered
            e.Handled = True

            ' the title page will have a gray background
            e.Graphics.FillRectangle(Brushes.LightGray, e.RectInsidePadding)

            Dim sf As StringFormat = Nothing
            Dim font As Font = Nothing

            Try
                sf = New StringFormat(StringFormatFlags.FitBlackBox)
                sf.Alignment = StringAlignment.Center
                sf.LineAlignment = StringAlignment.Center

                Dim text As String = "Infragistics Win\nPrinting Demo"

                font = New Font("Tahoma", 36.0F)

                e.Graphics.DrawString(text, font, Brushes.Black, RectangleF.op_Implicit(e.RectInsidePadding), sf)
            Finally
                'clean up
                If Not font Is Nothing Then font.Dispose()

                If Not sf Is Nothing Then sf.Dispose()
            End Try
        End If
    End Sub

    Private Sub UltraSchedulePrintDocument1_PagePrinted(ByVal sender As Object, ByVal e As Infragistics.Win.Printing.PagePrintedEventArgs) Handles UltraSchedulePrintDocument1.PagePrinted
        'note: the reprintpage must be honored by the print document and therefore
        'is implementation dependant
        e.ReprintPage = CType(sender, UltraPrintDocument).PageNumber = 1
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.Printing;

		private void ultraSchedulePrintDocument1_PageBodyPrinting(object sender, Infragistics.Win.Printing.PageBodyPrintingEventArgs e)
		{
			// when the first page is printed, prevent the regular
			// page body from being printed
			if (((UltraPrintDocument)sender).PageNumber == 1)
			{
				// mark the event as handled so page body of the print document will
				// not be rendered
				e.Handled = true;

				// the title page will have a gray background
				e.Graphics.FillRectangle(Brushes.LightGray, e.RectInsidePadding);

				using (StringFormat sf = new StringFormat(StringFormatFlags.FitBlackBox))
				{
					sf.Alignment = StringAlignment.Center;
					sf.LineAlignment = StringAlignment.Center;
				
					string text = "Infragistics Win\nPrinting Demo";

					using (Font font = new Font("Tahoma", 36f))
						e.Graphics.DrawString(text, font, Brushes.Black, e.RectInsidePadding, sf);
				}
			}
		}

		private void ultraSchedulePrintDocument1_PagePrinted(object sender, Infragistics.Win.Printing.PagePrintedEventArgs e)
		{
			//note: the reprintpage must be honored by the print document and therefore
			//is implementation dependant
			e.ReprintPage = ((UltraPrintDocument)sender).PageNumber == 1;
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also