Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

How to align several labels on bottom edge at run time

edited August 2003 in General
Hallo,

How can I align several labels on the same band on their bottom edge at run
time?
They can have different fonts and can be wordwrapped.

Thanks a lot for any idea!

Kind regards

Leo Kaploun

Comments

  • edited August 2003
    There is no "anchor" feature in RB that would do this. At design time, you
    would use the Align toolbar. At runtime, you'll have to let the labels
    generate. Then after they create a draw command to draw on the page, you can
    reposition the draw command to appear anchored to the bottom . You could
    even soft code the bottom if you took this approach, since the report engine
    already took the longest label into account when calculating the space used.
    Here is a simple example I just coded showing this technique. You'll also
    have to extend this demo to build a list of these draw command for each
    detail band that generates on each page object so that you can compare the
    right ones. I would create a class the holds a list of draw commands for a
    given detail band generation. Then create a function in your form that takes
    one of these object and figures out how to align only the label draw
    commands for a given object. That should work out pretty well IMO.

    http://www.digital-metaphors.com/tips/AnchorWordWrapLabels.zip


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited August 2003
    Thanks a lot Jim!

    I am sorry not to have mentioned that the band is a header band of the same
    height on every page. I guess that would make the solution simplier.

    Anyway I will try your solution first.

    Kind regards

    Leo Kaploun

  • edited August 2003
    Hallo again,

    I made the anchoring according to your tipp.

    Thanks a lot, it works great!

    Once more however: since the band the label are on is a header band, I would
    need to recalculate its height if the bottom most label position exceeds its
    original height. In this case the detail band's objects generated afterwards
    are overlayed with the header's ones.

    What is the simpliest was to do that assuming the header objects anchoring
    in occuring on ReportEndPage event?

    Kind regards.

    Leo Kaploun

  • edited August 2003
    If the label should be dynamic height, then use a TppMemo. The static label
    was what made the demo more complicated. The memo can stretch while the
    label can't. Then you'll get a dynamically resized draw text command and it
    should actually be easier to use to calculate the delta heights because the
    draw commands for the stretchable memo should already give you the correct
    stretched height so you don't have to calculate it as the demo did for
    static height labels.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.