Home General

How to position a control...

edited June 2011 in General

I have a report with (simplified) 2 controls:

TppDBMemo (Text of an invoice)
TppDBText (Sum of an invoice)

I want to align the Sum at the bottom of the Memo, which is stretchable
like this:

| |
| Memo |
| edInvoices | -------------
| | | edSum |
------------------- -------------

I tried in BeforePrint of the detailband:

edSum.Top := edInvoicesText.Top + edInvoicesText.Height - edSum.Height

but edInvoicesText.Height seems to be the height of the control *before*
it is stretched.

How can I achieve what I want?

Thanks Uli


  • edited June 2011
    Hi Uli,

    The report components themselves do not keep track of their stretchable

    One option is to measure the height of a line of text in the memo (using
    the TCanvas.TextHeight routine), then calculating how tall it is based
    on the amount of lines present.

    Another option is to use the DrawCommand values to reposition the other
    component. Something like the following.

    procedure TForm1.ppMemo1DrawCommandCreate(Sender, aDrawCommand: TObject);
    FBottom := TppDrawText(aDrawCommand).Top +
    TppDrawText(aDrawCommand).Height; //Get the bottom pos of the memo

    procedure TForm1.ppLabel1DrawCommandCreate(Sender, aDrawCommand: TObject);
    TppDrawText(aDrawCommand).Top := FBottom -
    TppDrawText(aDrawCommand).Height; //Use the memo pos to reposition


    Nico Cizik
    Digital Metaphors

    Best Regards,

    Nico Cizik
    Digital Metaphors
  • edited June 2011
    Hi Nico,

    Thank you very much for these hints. That helps.

    Regards Uli
  • edited June 2011
    Hi Nico,

    This code works perfectly!

    Thanks a lot.

    Regards Uli
This discussion has been closed.