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

accessing all children or components of a component

edited February 2005 in General
In one detail secton of a subreport I have about 32 controls

I want to set all visible to false except for 2 of them

what would be a good for loop for this

I have started something like this

procedure TForm.Button1click(Sender: TObject);
var
i : Integer;
begin
for i :- 1 to detailband.childcount do
begin
detailband.children // don't know where to go from here.
end;
end;

TIA

Comments

  • edited February 2005
    Hi Joey,

    Since you already know which band you need to loop through, there is no need
    to create the outer loop for the bands.

    ----------------------------------------------
    Tech Tip: Loop Thru All Objects in a Report
    ---------------------------------------------

    A ReportBuilder report is composed of a set of components. The basic
    structure is

    Reports.Bands[].Objects[]

    The bands and objects within the report can be accessed directly by object
    name or via the Bands and Objects array properties.

    Below is an example of using the Bands and Objects array properties to
    change the font for all objects on a report.


    uses
    ppClass;


    procedure AssignFontToReport(aFont: TFont; aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;

    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.HasFont then
    lObject.Font := aFont;

    end;

    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.