Skip to main content
A newer version of this page is available. .

Add Page Numbers

  • 2 minutes to read

The tutorial describes how to add page numbers to your reports.

Add Page Numbers

Do the following to insert page numbers in a report:

  1. To create a table report in this tutorial, start with a report that is bound to the “Products” table of the sample Northwind database (the nwind.mdb file included in the XtraReports installation). To learn more about binding a report to a data source, see Provide Data to Reports.
  2. In the Visual Studio Report Designer, switch to the Field List, select the ProductName and UnitPrice fields, and drag-and-drop them onto the report’s Detail band.

    HowTo - FilterDataReportLevel_0

  3. Create a PageFooterBand in your report. To do this, right-click anywhere in the report designer, and in the context menu point to Insert Band, and then click PageFooter.

    Shared_BandsGroupFooter

  4. Drop the XRPageInfo control from the DX.21.2: Report Controls Toolbox tab to the PageFooter band.

    Versions_DropControl_PageInfo

  5. To change the control’s display format, click its smart tag, and in the invoked actions list, specify the XRPageInfo.TextFormatString property (e.g., Page {0} of {1}, to display the current page number out of the total number of pages).

    PageInfo_1

The following image illustrates the resulting report:

PageInfo_4

Add Page Numbers for Groups

Do the following to make your report display page numbers for groups or detail reports:

  1. To create a table report in this tutorial, start with a report that is bound to the “Products” table of the sample Northwind database (the nwind.mdb file included in the XtraReports installation). To learn more about binding a report to a data source, see Provide Data to Reports. In this tutorial, we will start with the following report layout.

    HowTo_PageNumbers4Groups_5

  2. Group the report by the CategoryName field.
  3. To display the GroupFooter band, right-click anywhere on the report’s surface, and in the invoked menu, point to Insert Band and click GroupFooter.

    Shared_BandsAddGroupFooter

    Note

    You can force the group header and/or the group footer to be repeated on each page, using the GroupBand.RepeatEveryPage property.

  4. Next, force each new group to start on a separate page. Otherwise, group page numbers will be calculated incorrectly.

    To do this, select the Group Footer, and set its Band.PageBreak to AfterBand.

    HowTo_PageNumbers4Groups_0

  5. From the DX.21.2: Report Controls toolbox tab, drop the XRPageInfo control onto the GroupFooter (or GroupHeader) band.

    HowTo_PageNumbers4Groups_1

  6. Select the created control, and set its XRPageInfo.RunningBand property to GroupHeader1.

    HowTo_PageNumbers4Groups_2

    Tip

    You can use the XRPageInfo.TextFormatString and XRPageInfo.PageInfo properties to adjust the way the control represents its contents.

The following image illustrates the resulting report:

HowTo_PageNumbers4Groups_4