IDocumentModifier.GetPageIndexByID(Int64) Method

Returns the index of the page whose Page.ID is specified as a parameter.

Namespace: DevExpress.XtraReports

Assembly: DevExpress.Printing.v20.2.Core.dll


int GetPageIndexByID(
    long id
Function GetPageIndexByID(
    id As Long
) As Integer


Name Type Description
id Int64

The page ID.


Type Description

The page index that corresponds to the page ID passed as a parameter.


To use the GetPageIndexByID method, get a required page's ID beforehand. For example, you can use the XRControl.PrintOnPage event to get the ID of the page on which a particular control is contained. The example below demonstrates how to insert another report's pages at a particular position. This position is the first page that includes the "CategoryName" label.

public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport {
    long? categoryStartPageID;
    private void XtraReport1_AfterPrint(object sender, EventArgs e) {  
        //Create the 2nd report and generate its document.
        XtraReport2 report2 = new XtraReport2();

        if(IsDisposed || categoryStartPageID == null)
        // Add the 2nd report's pages alternating them with the 1st report pages,
        // starting from the 'categoryStartPageID' page
        ModifyDocument(x => {
            int categoryStartPageIndex = x.GetPageIndexByID(categoryStartPageID.Value);
            categoryStartPageID = null;

            for(int i = 0; i < report2.Pages.Count; i++) {
                int insertIndex = categoryStartPageIndex + 1 + i * 2;
                if(insertIndex >= x.PageCount)
                x.InsertPage(insertIndex, report2.Pages[i]);
    private void lbCategoryName_PrintOnPage(object sender, PrintOnPageEventArgs e) {
        if(IsDisposed || categoryStartPageID != null)
        categoryStartPageID = Pages[e.PageIndex].ID;

The Page.Index property is not recommended for this scenario because it can change during document generation.


A reference to a page is not recommended in this scenario because it changes if you use caching during document generation (see CachedReportSource).

See Also