I have a report that has a group field that needs to force a page break when its value changes. I want to print this field along with several other group fields, and then the detail records and then move to the next row in the data grid. When the group field changes value I want to generate a new page and print the header fields and then resume the detail records.
Currently the report is breaking the page when the field changes, but if the next detail report will fit onto the remaining space it prints the records there.
To accomplish this task you can either add a GroupFooter band and set the GroupFooter.PageBreak to AfterBand.
or put a XRPageBreak control, handle the Detail.BeforePrint and adjust the visibility of the XRPageBreak as you need.
To get processing row you need to use the XtraReport.GetCurrentRow() method.
Please try this solution, and let us know the results.
I am not sure of what you are suggesting. As I have the report built I have a group header band with several fields. What field would I use for the group footer band and how would I make sure that it forces a page break when the label in the group header changes? I have selected the option of group union to whole page, keep together and print on every page for the current group header.
IF I elect to use the XRPageBreak control, can the getcurrentrow be compared to the next row in order to activate (make visible) the pagebreak? If I understand what you are suggesting, I would need to compare the datagrid values for the current row and compare with the datagrid value of the next row and if different I would make the XRPageBreak visible. Is that correct, and if so, does the XtraReport allow the next row to be printed to be processed?
Assuming that you set the GroupFooter.PageBreak option to AfterBand, the page break will be made automatically when the group field changes its value, and a new group begins.
As for comparing values from the current, next and previous rows, yes, it's possible. Please use the XtraReport.GetNextColumnValue(), XtraReport.GetPreviousColumnValue() and XtraReport.GetCurrentColumnValue() to obtain these values.
Attached is a sample project, demonstrating both approaches in action. Please let me know whether this helps you.