How to access components dinamically loaded
Hi
I have a blank report and one report file (template) that have components
inside (ps: component TppDBText with name DBText0).
Dinamically I load the template file to a subreport, twice, creating
subreport1 and subreport2.
In design mode, I know the assigned names of the component, in the first
subreport, it'll called DBText0, in the second subreport, it'll called
DBTextX.
How can I access the loaded components of the subreport to change their
properties, without know the names of the components and without have the
components in compile time?
regards,
Fred
I have a blank report and one report file (template) that have components
inside (ps: component TppDBText with name DBText0).
Dinamically I load the template file to a subreport, twice, creating
subreport1 and subreport2.
In design mode, I know the assigned names of the component, in the first
subreport, it'll called DBText0, in the second subreport, it'll called
DBTextX.
How can I access the loaded components of the subreport to change their
properties, without know the names of the components and without have the
components in compile time?
regards,
Fred
This discussion has been closed.
Comments
You will need to loop through all the objects in your report once you have
loaded the templates into each subreport. See the article below on how to
do this.
----------------------------------------------
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;
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com