The requested page is not available for the requested platform. You are viewing the content for Default platform.

PrintOnPageEventHandler Delegate

A method that will handle the XRControl.PrintOnPage event.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

public delegate void PrintOnPageEventHandler(
    object sender,
    PrintOnPageEventArgs e
);
Public Delegate Sub PrintOnPageEventHandler(
    sender As Object,
    e As PrintOnPageEventArgs
)

Parameters

Name Type Description
sender Object

An object of any type that triggers the XRControl.PrintOnPage event.

e PrintOnPageEventArgs

A PrintOnPageEventArgs object that provides data for the XRControl.PrintOnPage event.

Remarks

When you create a PrintOnPageEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.

Examples

The following example demonstrates how to use the XRControl.PrintOnPage event. The event handler below checks if an xrLabel1 is being printed on the last page (in case the PrintOnPageEventArgs.PageCount property is equal to PrintOnPageEventArgs.PageIndex minus 1), and, if yes, sets its text to "The last page!". Otherwise, it checks if a label is being printed on the odd page, and, if yes, it cancels its printing.

using DevExpress.XtraReports.UI;
// ...

private void xrLabel1_PrintOnPage(object sender, PrintOnPageEventArgs e) {
    // Check if the label is printed on the last page.
    // Note that the PageCount property value is not valid if you
    // use the CachedReportSource component to generate a report document
    if (e.PageIndex == e.PageCount-1)
        // Set its text.
        ((XRLabel)sender).Text = "The last page!";
    else
        // Check if the label is printed on the odd page.
        if (e.PageIndex % 2 == 0)
            // Cancel its printing.
            e.Cancel = true;
}
See Also