How to position a control...
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
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
This discussion has been closed.
Comments
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
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thank you very much for these hints. That helps.
Regards Uli
This code works perfectly!
Thanks a lot.
Regards Uli