Aligning text vertically in a dynamic height detailband
Hi,
Delphi 2009, RB15.05.
I know questions like this have been asked before, but I've been unable
to find a solution that actually works, possibly because in the other
situations the detail band was not dynamic.
We have a simple report with a memofield that is set to autosize (thus
stretching the detail band with it) and a label next to it that we would
like to be positioned vertically central within the band, as in the
example below which shows three records / detail bands:
------------------------------------------------------
Very short memo Label field
------------------------------------------------------
Some long memo
text here, 3 Label field
lines....
------------------------------------------------------
Some even longer
memo text here.
This is a different Label field
detail band with
more lines
------------------------------------------------------
I have tried fiddling with the DrawCommandCreate events of various
components and putting code in to change the Top position of the label
field in just about every other event, but nothing seems to work. I
wonder if I'm missing something obvious? Also, the help says there's a
property of TppDrawCommand called ClipRect, but this does not seem to be
available in RAP.
Any advice appreciated,
Thanks.
Delphi 2009, RB15.05.
I know questions like this have been asked before, but I've been unable
to find a solution that actually works, possibly because in the other
situations the detail band was not dynamic.
We have a simple report with a memofield that is set to autosize (thus
stretching the detail band with it) and a label next to it that we would
like to be positioned vertically central within the band, as in the
example below which shows three records / detail bands:
------------------------------------------------------
Very short memo Label field
------------------------------------------------------
Some long memo
text here, 3 Label field
lines....
------------------------------------------------------
Some even longer
memo text here.
This is a different Label field
detail band with
more lines
------------------------------------------------------
I have tried fiddling with the DrawCommandCreate events of various
components and putting code in to change the Top position of the label
field in just about every other event, but nothing seems to work. I
wonder if I'm missing something obvious? Also, the help says there's a
property of TppDrawCommand called ClipRect, but this does not seem to be
available in RAP.
Any advice appreciated,
Thanks.
This discussion has been closed.
Comments
One option would be to manually measure the height of the memo before
the band prints, then size the label to the identical height (with its
vertical alignment set to center).
See the TppMemo.CalcSpaceUsed for how we calculate the size of a memo.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for the reply, but I'm a bit confused. I've had a look at
CalcSpaceUsed, but it seems to rely on other methods (methods of
TppPlainText, among others) that aren't available in RAP.
Is there no suitable event that I can use to get the final height of the
memo field and adjust the second field accordinly? On the surface, it
seems such a simple thing to want to do!
Thanks,
Steve