[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Collapse]Reporting
 [Expand]Product Information
 [Expand]Get Started with DevExpress Reporting
 [Expand]Create Popular Reports
 [Expand]Detailed Guide to DevExpress Reporting
 [Expand]Visual Studio Report Designer
 [Collapse]Create End-User Reporting Applications
   Cross-Platform Reporting
  [Collapse]WinForms Reporting
   [Collapse]Print API
     Print a Report
     Print Multiple Reports in a Batch
     Specify Print Settings
     Specify the Number of Copies to Print
     Manage the Print Progress
     Print a Specified Range of Report Pages
     Specify the Paper Source and Printer Resolution
     Obtain the Current Page Number when Printing a Control
   [Expand]Print Preview
   [Expand]End-User Report Designer
   [Expand]Application Security
   [Expand]Application Appearance
    Application Deployment
   [Expand]Localization
    End-User Documentation
  [Expand]WPF Reporting
  [Expand]Web Reporting
  [Expand]WCF Report Service
  [Expand]Discontinued Platforms
   Localization
   Redistribution and Deployment
 [Expand]API Reference
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Obtain the Current Page Number when Printing a Control

This example demonstrates how to obtain the number of the page that is currently printing.

You can obtain both the current and total number of document pages using the PrintOnPageEventArgs.PageCount and PrintOnPageEventArgs.PageIndex properties in the XRControl.PrintOnPage event handler. The PrintOnPageEventArgs.PageIndex property indicates the zero-based page index.

Tip

The XRControl.PrintOnPage event is raised after both the XRControl.BeforePrint and XRControl.AfterPrint events. See Report Events for more information.

Tip

You need to handle the corresponding script event to serialize your custom logic with the report's definition and maintain it in end-user applications.

Consider using the XRPageInfo control for displaying page numbers in a report.

Is this topic helpful?​​​​​​​