Value of a ppLablel does not change at run time.
I have the folowing code and the values of the ppLabels does not change at
runtime. what have I done wrong !
Thanks in Advance.
MyReport := TppReport.Create(self);
MyReport.Template.DatabaseSettings.NameField := 'REPORTNAME';
MyReport.Template.DatabaseSettings.TemplateField := 'TEMPLATE';
MyReport.Template.DatabaseSettings.DataPipeline := Reportpl;
MyReport.Template.DatabaseSettings.Name := 'By Company';
MyReport.Template.LoadFromDatabase;
for i := 0 to MyReport.ComponentCount - 1 do
begin
if (Components[i] is TppLabel) then
begin
if (MyReport.Components[i] as TppLabel).UserName = 'Label16' then
(MyReport.Components[i] as TppLabel).Caption :=
ConvertDate(_FromDATE);
if (Components[i] as TppLabel).UserName = 'Label15' then
(Components[i] as TppLabel).Caption := ConvertDate(_ToDATE);
end;
end;
runtime. what have I done wrong !
Thanks in Advance.
MyReport := TppReport.Create(self);
MyReport.Template.DatabaseSettings.NameField := 'REPORTNAME';
MyReport.Template.DatabaseSettings.TemplateField := 'TEMPLATE';
MyReport.Template.DatabaseSettings.DataPipeline := Reportpl;
MyReport.Template.DatabaseSettings.Name := 'By Company';
MyReport.Template.LoadFromDatabase;
for i := 0 to MyReport.ComponentCount - 1 do
begin
if (Components[i] is TppLabel) then
begin
if (MyReport.Components[i] as TppLabel).UserName = 'Label16' then
(MyReport.Components[i] as TppLabel).Caption :=
ConvertDate(_FromDATE);
if (Components[i] as TppLabel).UserName = 'Label15' then
(Components[i] as TppLabel).Caption := ConvertDate(_ToDATE);
end;
end;
This discussion has been closed.
Comments
to access the TppLables you need. Below is more on creating and using
Report Object loops.
----------------------------------------------
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
I have another problem during the above situation I have to switch the
visiblity of a TppGroupFooterBand programaticaly. Rather than refering it by
name is there a way where I can refer to it like Group Footer[1] etc. Is
that possible ?
I tried with:
if aReport.Bands[liBand].Index = 2 then
But that does not work.
Thanks in Advance.
There are a few ways to access a group footer by index...
1. Use the Report.Groups[].FooterBand property.
2. Use the Report.GroupFooter[] property. This method is probably the
easiest.
3. You could loop through the report bands by using the Report.Bands[]
property and find all instances of a Groupfooter (if you are trying to find
a certian groupfooter). This is similar to the object loop example I gave
you in the last post.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com