views:

511

answers:

1

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

+1  A: 

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.

Kyle Gagnet
I like the second and will try and test. Appreciate the effort, so I'm going to mark as answered; see no reason why it wouldn't work.
Jeff O
I tested both methods and they worked for me, so please comment if you can't get it to work.
Kyle Gagnet