test

progging - To wander about and beg; to seek food or other supplies by low arts; to seek for advantage by mean shift or tricks.
progging - Programmer slang for writing computer code.

fredag 5. august 2011

Hiding fields in QuickReport

After getting the image into the report, the next task was to hide it :-) Given a certain condition, part of the report should not be shown. So I had to hide some of the report fields in run-time.

This is done by handling the xxBeforePrint() events, finding the correct controls and set the Enabled property to false. I didn't have a lot of documentation on the QuickReport so it involved a bit of trial and error. The solution:

1. First hook up the event handler at some appropriate place
  // In order to disable LT analysis if not activated
if RptFrm_Header.QuickReport.Bands.HasTitle then begin
RptFrm_Header.QuickReport.Bands.TitleBand.BeforePrint := QRFuelRepHeaderBeforePrint;
end;
2. In the event handler, find the right controls and disable them
procedure TFrm_FuelRep.QRFuelRepHeaderBeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean);
const
controlNames : array[0..2] of string =
(
'ReportLabelLT_Status',
'DBImageLT_Status',
'DBTextLT_Status'
);
var
name: string;
component: TComponent;
begin
for name in controlNames do begin
component := RptFrm_Header.FindComponent(name);
if (component <> nil) and (component is TControl) then begin
(component as TControl).Enabled := False;
end;
end;
end;

Ingen kommentarer:

Legg inn en kommentar