Merging of Section reports not working via Pages.AddRange

Posted by: steve_goa on 4 June 2023, 10:38 pm EST

    • Post Options:
    • Link

    Posted 4 June 2023, 10:38 pm EST

    Hi,

    Using: ActiveReports v16, Visual Studio .NET v4.8.1 WinForms application

    I’m trying this code to merge a 2nd report into the 1st report but its not working:

    ddRpt = new rptA();
    
    ddRptB = new rptB();
    ddRptB.Run(false);
    
    ddRpt.Document.Pages.AddRange(ddRptB.Document.Pages);
    
    frmPreview pvPreview = new frmPreview();
    pvPreview.ARViewer1.LoadDocument(ddRpt);
    Application.Run(pvPreview);

    When it opens the preview, it displays only the page from the first report. Any idea what could be wrong and how to resolve this? Thanks in advance!

  • Posted 6 June 2023, 4:02 pm EST

    Hi Steve,

    You’ll also need to ‘Run()’ your main report (‘ddRpt’) and load the ddRpt.Document in the viewer.

    Running your ddRpt will render the first report into the report.Document and merging the pages from the second report will append the pages to your ddRpt.Document which you can load in the viewer.

    Refer to the code snippet below:

    ddRpt = new rptA();
    ddRpt.Run();
    
    ddRptB = new rptB();
    ddRptB.Run(false);
    
    ddRpt.Document.Pages.AddRange(ddRptB.Document.Pages);
    
    frmPreview pvPreview = new frmPreview();
    pvPreview.ARViewer1.LoadDocument(ddRpt.Document);
    Application.Run(pvPreview);
    

    Please find attached a sample implementing the same.

    Regards,

    Anand

    MergingReports.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels