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

How to position a control...

edited June 2011 in General
Hi,

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

Comments

  • edited June 2011
    Hi Uli,

    The report components themselves do not keep track of their stretchable
    height.

    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);
    begin
    FBottom := TppDrawText(aDrawCommand).Top +
    TppDrawText(aDrawCommand).Height; //Get the bottom pos of the memo
    end;

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


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • 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.