Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

How to loop through all controls with subreports

edited April 2002 in General
I want to loop through all the controls on my report setting font colour. I
have tried the code from the tip:

for liBand := 0 to aReport.BandCount-1 do
for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do begin
lObject := aReport.Bands[liBand].Objects[liObject];
if lObject.HasFont then
lObject.Font.color := clRed;
end;

But this does not include any controls within subreports.

How do I really loop through *all* the controls including those on
subreports??

Sarah

Comments

  • edited April 2002
    You have to recursively descend into the subreport to update it's
    components.

    procedure UpdateReportFonts(aReport: TppCustomReport)
    var
    ...
    begin
    for liBand := 0 to aReport.BandCount-1 do
    for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
    begin
    lObject := aReport.Bands[liBand].Objects[liObject];

    => if (lObject is TppSubreport) then
    => UpdateReportFonts(TppSubreport(lObject).Report);

    else if lObject.HasFont then
    lObject.Font.color := clRed;
    end;
    end;

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

  • edited April 2002
    Thanks, this could be usefully added to the "Loop thru All Objects in a
    Report" tip

    Sarah
This discussion has been closed.