Question

I have a report with a group header and footer. There should be only two groups based on the data. I have the Group Footer set to have a page break after it. I don't want the last Group to create a page break before the Report Footer (If I did, I would set the report footer to have a page break before it.). I've never had this problem with other report writers.

Example of what the report printout looks like and not the design. My report only has one group header and one group footer:

Report Header

Group Data Set 1 Header detail detail detail Group Data Set 1 Footer

Group Data Set 2 Header Detail Detail GroupData Set 2 Footer ! I don't want this!

Report Footer (stuck on last page by itself)

Posted on their board: http://community.devexpress.com/forums/t/78705.aspx

Was it helpful?

Solution

This determines when you've reached the end of the report and stops the group footer from breaking the page. It assumes that your group footer's PageBreak property is already set to PageBreak.AfterBand.

private void Report_DataSourceRowChanged(object sender, DataSourceRowEventArgs e) {
    if (e.CurrentRow == this.RowCount - 1)
        GroupFooter.PageBreak = PageBreak.None;
}

Alternatively, you could set both your group header and footer's PageBreak property to PageBreak.None. Then when you're printing the first group, set it to page break before each group header band like so:

private void GroupFooter_BeforePrint(object sender, DataSourceRowEventArgs e) {
    if (GroupHeader.PageBreak == PageBreak.None)
        GroupHeader.PageBreak = PageBreak.BeforeBand;
}

It's up to you which method to choose. Personally I like the 2nd one better. Even though I arbitrarily picked the GroupFooter_BeforePrint method to subscribe and make this change, I would still feel more comfortable doing that than relying on row counts to determine when you've reached the end of the report.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top