Programmatically Insert Page Break in ActiveReports

13,146

There are two ways to do this and the best option depends on the data and your report.

Option 1: Page Break Control You can add the PageBreak control to the report in a specific location and programatically set the Enabled property of the PageBreak control to determine whether it creates a page break or not. See this page for documentation on the Enabled property of the PageBreak control:

Option 2: Section.New Page The other option is to use the NewPage property of the section. In this case you can set the NewPage property of the Detail or GroupHeader or GroupFooter section to trigger a page break. Try setting it from the Format event of the section. See this page for documentation on the NewPage property.

The support forums dedicated to ActiveReports support on the GrapeCity website are active and also a great way to get suggestions and help on ActiveReports.

Hope this helps!

EDIT : Links fixed

Share:
13,146
Kevin Babcock
Author by

Kevin Babcock

Gig 'em!

Updated on June 16, 2022

Comments

  • Kevin Babcock
    Kevin Babcock almost 2 years

    I've been scouring the web for a good example, but cannot figure out how to add a page break to an ActiveReports report programmatically. The reports I'm working with usually require 1-2 pages for each record. In order to support dual-sided printing of the reports I want to insert a blank page for each record that uses an odd number of pages, ensuring that each new record is printed on the front of each printed page.

    I'm very new to ActiveReports, so any suggestions, code samples, or links are much appreciated!

  • Kevin Babcock
    Kevin Babcock about 14 years
    I already have a PageBreak control in the report. I found that inserting a second PageBreak control (and controlling whether or not it is enabled programmatically) does not cause a second page to be inserted. I also tried to use the Section.NewPage suggestion in the Detail section of the report, but that does not insert a new page. I think it's b/c of the PageBreak that is already there. I found that if I remove the PageBreak, then Section.NewPage works. But that doesn't help b/c I need the PageBreak there to ensure records start on a fresh page.
  • Kevin Babcock
    Kevin Babcock about 14 years
    So this was not quite a solution for me, but +1 for the good suggestions. Thanks for your response!
  • Scott Willeke
    Scott Willeke about 14 years
    Make sure you are using the Format event of the section containing the control to enable/disable the pagebreak control. BeforePrint/AfterPrint events are definitely too late and other events (e.g. FetchData) are not in sync with the sections. If you continue to have problems I encourage you to upload your report to the support forums I linked to in my answer and I am sure someone will help you get what you want.
  • Mac Sigler
    Mac Sigler almost 11 years
    Code example: if (pageBreaks) { groupFooter1.NewPage = GrapeCity.ActiveReports.SectionReportModel.NewPage.After; }
  • thecoolmacdude
    thecoolmacdude almost 10 years
    @activescott All of your links are expired.