Back to Devexpress

XtraReport.Pages Property

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xtrareport-51ac6bad.md

latest8.3 KB
Original Source

XtraReport.Pages Property

Gets a collection of pages generated for this report.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
[Browsable(false)]
public PageList Pages { get; }
vb
<Browsable(False)>
Public ReadOnly Property Pages As PageList

Property Value

TypeDescription
PageList

A PageList object, specifying a collection of pages.

|

Remarks

After calling the XtraReport.CreateDocument method (or after calling the PrintTool.ShowPreview or PrintTool.ShowPreviewDialog methods for the first time), you can access all pages of the generated Document using the Pages property.

The PageList object, which is the returned collection of pages, exposes methods that allow you to reorder and remove pages, as well as to add and insert pages from other reports (see Merging Reports for details).

The following code reorders document pages to produce a booklet (first page, last page, second page, last but one, third page, etc.):

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

private void CreateBooklet() {
    // Create the 1st report and generate its document.
    XtraReport1 report1 = new XtraReport1();
    report1.CreateDocument();

    // Preserve the original page numbers on all pages.
    report1.PrintingSystem.ContinuousPageNumbering = false;

    // Create a booklet.
    int centerPageIndex = Convert.ToInt32((report1.Pages.Count - 1) / 2);
    for (int i = 0; i < centerPageIndex; i++) {
        report1.Pages.Insert(i * 2 + 1, report1.Pages[report1.Pages.Count - 1]);
    }

    // Show the Print Preview form (in a WinForms application).
    ReportPrintTool printTool = new ReportPrintTool(report1);
    printTool.ShowPreviewDialog();
}
vb
Imports DevExpress.XtraReports.UI
' ...

Private Sub CreateBooklet()
    ' Create the 1st report and generate its document.
    Dim report1 As XtraReport1 = New XtraReport1()
    report1.CreateDocument()

    ' Preserve the original page numbers on all pages.
    report1.PrintingSystem.ContinuousPageNumbering = False

    ' Create a booklet.
    Dim centerPageIndex As Integer = Convert.ToInt32((report1.Pages.Count - 1) / 2)
    Dim i As Integer = 0
    Do While i < centerPageIndex
        report1.Pages.Insert(i * 2 + 1, report1.Pages(report1.Pages.Count - 1))
        i += 1
    Loop

    ' Show the Print Preview form (in a WinForms application).
    Dim printTool As New ReportPrintTool(report1)
    printTool.ShowPreviewDialog()
End Sub

You can also add an empty page using the PrintingSystemBase.CreatePage method of the report’s XtraReport.PrintingSystem.

Use the PrintingSystemBase.ContinuousPageNumbering property to specify whether to update the page numbers after customizing the collection of pages or preserve the page numbers from the original document(s).

The following code snippets (auto-collected from DevExpress Examples) contain references to the Pages property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

reporting-winforms-custom-table-of-contents/CS/CustomTableOfContents/Form1.cs#L28

csharp
//Merge reports
categoriesReport.Pages.AddRange(productsReport.Pages);

reporting-winforms-watermark-different-pages/CS/Form1.cs#L24

csharp
// Add a custom watermark to the second page.
Page myPage = report.Pages[1];
myPage.WatermarkId = "Watermark2";

reporting-winforms-salary-reports/CS/SalaryReports/Reports/ManagementReport.cs#L40

csharp
this.PrintingSystem.ContinuousPageNumbering = true;
    this.Pages.Insert(0, titleReport.Pages[0]);
}

reporting-winforms-add-vertical-brick/CS/T457705/XtraReport1.cs#L18

csharp
size.Width = size.Width + 50;
foreach (Page page in this.Pages) {
    LabelBrick labelBrick = CreateLabel(page, font, size, text);

reporting-winforms-best-fit-table-row-height/CS/dx_sample/XtraReport1.cs#L24

csharp
if (DetailHeight != 0) return;
foreach (DevExpress.XtraPrinting.Page p in this.Pages) {
    foreach (Brick b in p) {

reporting-winforms-custom-table-of-contents/VB/CustomTableOfContents/Form1.vb#L28

vb
'Merge reports
categoriesReport.Pages.AddRange(productsReport.Pages)
Call CustomTableOfContents.Form1.CreateLinks(categoriesReport)

reporting-winforms-watermark-different-pages/VB/Form1.vb#L26

vb
' Add a custom watermark to the second page.
Dim myPage As Page = report.Pages(1)
myPage.WatermarkId = "Watermark2"

reporting-winforms-salary-reports/VB/SalaryReports/Reports/ManagementReport.vb#L35

vb
Me.PrintingSystem.ContinuousPageNumbering = True
    Me.Pages.Insert(0, titleReport.Pages(0))
End Sub

reporting-winforms-add-vertical-brick/VB/T457705/XtraReport1.vb#L17

vb
brickSize.Width = brickSize.Width + 50
For Each page As Page In Me.Pages
    Dim labelBrick As LabelBrick = CreateLabel(page, brickFont, brickSize, brickText)

reporting-winforms-best-fit-table-row-height/VB/dx_sample/XtraReport1.vb#L28

vb
End If
For Each p As DevExpress.XtraPrinting.Page In Me.Pages
    For Each b As Brick In p

See Also

Merge Reports

XtraReport Class

XtraReport Members

DevExpress.XtraReports.UI Namespace