Dynamic Caption Setting and autosizing for TppLabel, is it possible ?
Hello,
I am working on ReportBuilder 6.02 Standard, Windows 2000 and
Delphi 5.0.
I need to change the caption of a label during the beforePrint or
beforeGenerate events.
The label, even when set to autosize, would not grow in
width after its caption have been changed.
I am using (or trying to use) the new width of this label
to align another label to its right side.
I noticed that in the TppPrintable.setCaption method you
call adjustBounds and in there the code is checking if the report is
printing
and that is why my label does not get wider or thinner.
what can I do ?!?! this should be very simple or am I missing something ??
Should I use another component for dynamic captions ?
Thanks in advance,
Roy Waxman.
I am working on ReportBuilder 6.02 Standard, Windows 2000 and
Delphi 5.0.
I need to change the caption of a label during the beforePrint or
beforeGenerate events.
The label, even when set to autosize, would not grow in
width after its caption have been changed.
I am using (or trying to use) the new width of this label
to align another label to its right side.
I noticed that in the TppPrintable.setCaption method you
call adjustBounds and in there the code is checking if the report is
printing
and that is why my label does not get wider or thinner.
what can I do ?!?! this should be very simple or am I missing something ??
Should I use another component for dynamic captions ?
Thanks in advance,
Roy Waxman.
This discussion has been closed.
Comments
event handler to concatenate the strings together, instead of using mutiple
labels and trying to resize them and align them together.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Thanks for the reply,
This cannot be done by concatenating strings because each label has
different font styles.
one label is the caption (bold) and the other is the data. We must use 2
labels.
We found a strange solution for this by using another RB Report component
with only a label on it
just to calculate the width for a certain caption.
Bye.
value of the right of ppLabel1. I used the printer canvas to get the text
width, then converted it to my report units which are in inches.
uses
ppUtils, ppTypes;
procedure TForm1.ppDetailBand1BeforePrint(Sender: TObject);
var
ldTextWidth: Double;
liWidth: Integer;
lCanvas: TCanvas;
begin
ppLabel1.Caption := 'Caption 1';
ppLabel2.Caption := 'Caption 2';
lCanvas := ppReport1.Printer.Canvas;
lCanvas.Font := ppLabel1.Font;
liWidth := lCanvas.TextWidth(ppLabel1.Caption);
{convert printer pixels to microns}
ldTextWidth := ppToMMThousandths(liWidth, utPrinterPixels, pprtHorizontal,
ppReport1.Printer);
{convert microns to report units (inches)}
ldTextWidth := ppFromMMThousandths(Round(ldTextWidth), utInches,
pprtHorizontal, ppReport1.Printer);
ppLabel2.Left := ppLabel1.Left + ldTextWidth;
end;
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
you to format the text as desired and position the second label using a tab.
------------------------------------
Bruce Roberts
Roberts Browne Limited
RBAddOn Components for Report Builder
http://www.bancoems.com/rbaddon.htm