Breaking data and keeping it together |
Top Previous Next |
In this section, we will look at two modes of data printing - "Break" and "Keep together".
In an regular band printing mode, FastReport checks if there is enough space on the current page to print a band. If there is not, the band is printed wholly on the next page. If the "CanBreak" property of the band is enabled, FastReport will try to print the part of the band on the available space, that is, "break" it.
An attempt to break a band can be either successful or not. It depends on the type of object which has been placed on the band, and its settings. The following objects can be broken:
These objects have the "CanBreak" property as well. If it is enabled, then the object can be broken. Non-breakable objects are always displayed wholly, there, where they have enough place.
In the figure below, how a band can be broken is shown.
Break algorithm does not always work correctly. The artifacts can occur in a situation, when there are several objects with different font size on a band.
The goal of band breaking is to save the space on the printed sheet. Data keeping's goal is contrary: display a set of bands wholly on one sheet. In this case there will be a lot of unused space on the sheets, but the data is printed in a way that it is comfortable to percept.
The "keep together" mechanism allows keeping a set of bands together on one page (or column, if the report has columns). If, when printing, kept data reaches the end of the page, FastReport relocates all data which has been printed already onto a new page.
You can use the "keep together" in the following cases:
Let us look at the use of "keep together" mechanism.
To keep together all data rows or group elements (header, data, footer), enable the "KeepTogether" property. This property is used in the "Data" and "Group Header" bands. The figure below shows how data is printed with and without keeping together:
To keep master data row together with detail data rows, enable the "KeepDetail" property of the "Data" band. This property is used in a report of "master-detail" type:
To prevent "hanging" headers and footers, use the "KeepWithData" property. The following bands have got this property:
This property allows to keep header/footer with at least one data row:
In order to keep a band and its child band together, enable the "KeepChild" property. |