[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.


procedure TExpressionsDemo.DoBeforePrint(Sender: TFPReportElement);
  With rpt.Variables.FindVariable('isEven') do
    AsBoolean:=Not AsBoolean;
  if rpt.Variables.FindVariable('isEven').AsBoolean then
    Sender.Frame.BackgroundColor := clLtGray
    Sender.Frame.BackgroundColor := clWhite;


fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

My public PGP key:  http://tinyurl.com/graeme-pgp

More information about the lazarus mailing list