|Top Previous Next|
There can be a problem when one field in a label-type report has content of variable length. To simulate this in our example, let's reduce the width of the Bio.“Common Name” object to 2.5 cm and enable the “Stretch” property for this object and also for the “First level data” band. Enable all the frame lines for all the objects so that the effects of the stretching function are clear to see. The design now outputs a report like this:
Here the first Bio.“Common Name” field object contains a lot of text and is stretched into two lines. This causes the Bio.“Length (cm)” field object, located beneath it, to be shifted downwards. This happens because all the objects have their “ShiftMode” property set to smAlways by default, meaning they shift downwards if there is a stretchable object (a “Text” object with the “Stretch” property enabled) above them. The distance shifted depends on how much the object above is stretched.
But this is not want we want to happen on our label - we want the “Length, cm.” object also to be shifted by the same amount. This can be achieved by using a special FastReport band type called the “Child” band. A “Child” band is linked to (and displayed after) its parent band. Add a “Child” band to the design and drag the two “Text” objects into it, as shown here:
Link the MasterData band to the Child band, by setting its “Child” property to “Child1” in the object inspector. Now, each time the MasterData band prints, the Child band is printed immediately after it:
The “Length, cm:” title now lines up exactly with its value field “50”. To prevent a child band from being moved to the next page if there is insufficient white space on the page (and becoming so-called 'orphaned' from its parent band), enable the “KeepChild” property of the parent band in the object inspector.