[Lazarus] lazreport: how to use global report variables
mailinglists at geldenhuys.co.uk
Tue Jun 30 15:03:19 CEST 2015
I have a print dialog, shown before the report is generated. The user
can make some selections. Based on that, I want to set the value of a
global variable, then use that variable to decide if a column of data
must be visible or not.
I've used File -> Variable List to define a new variable (just the name).
I then double clicked on a header memo field and enabled the Script
checkbox, and typed in the following code in the Script box:
if [ HideKlas] = '0' then
Visible := True
Visible := False;
In my *.pas unit I temporarily tried to set a hard-coded value of the
"HideKlas" variable to see what happens in the report. I tried both the
values '0' and '1'.
If FRPrint.PrepareReport then
FRPrint.Variables.Values['HideKlas'] := '1'; // for testing only
FRPrint.Preview := FAfdrukForm.PrintPanel;
No matter what I do, the header (memo) field is now _always hidden_.
Changing the hard-coded value of the variable doesn't seem to make any
Before any of the above script changes the report worked, and the header
text was visible. But I can't seem to make that visibility a dynamic option.
Any tips would be much appreciated.
- Graeme -
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
More information about the Lazarus