[Lazarus] Lazreport variables
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Mon May 11 16:12:16 CEST 2020
On 03/05/2020 5:03 pm, Santiago A. via lazarus wrote:
> I want to write a report where even lines are written with no background
> and odd lines with a light gray background.
Have you considered using the newer FPReport (aka fcl-report) included
with FPC? There is a report designer for Lazarus too. It is super simple
to implement the alternating colors that you required. Take a look at
the fcl-report/demos/ directory and look at the "rptexpressions.pas"
unit. All you need to do is assign the alternating colors in the
DoBeforePrint() event handler.
eg:
procedure TExpressionsDemo.DoBeforePrint(Sender: TFPReportElement);
begin
With rpt.Variables.FindVariable('isEven') do
AsBoolean:=Not AsBoolean;
if rpt.Variables.FindVariable('isEven').AsBoolean then
Sender.Frame.BackgroundColor := clLtGray
else
Sender.Frame.BackgroundColor := clWhite;
end;
Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the lazarus
mailing list