Finding an object by Name
Hi,
I have a number of DBText objects in my report; let's call them DBText1,
DBText2, DBText3, DBText4.
I want to assign the fieldname property of the object depending on some
criteria. In effect I want to do something like this (as you would do
in Delphi) in a loop:
for i := 1 to 4 do
(FindControl('DBText' + inttostr(i)) as TField).FieldName := 'fld' +
inttostr(i)
I hope I have explained this well enough. Is there a routine in RAP to
find a component based on name when the name needs to be found based on
other criteria?
Thanks
Al
I have a number of DBText objects in my report; let's call them DBText1,
DBText2, DBText3, DBText4.
I want to assign the fieldname property of the object depending on some
criteria. In effect I want to do something like this (as you would do
in Delphi) in a loop:
for i := 1 to 4 do
(FindControl('DBText' + inttostr(i)) as TField).FieldName := 'fld' +
inttostr(i)
I hope I have explained this well enough. Is there a routine in RAP to
find a component based on name when the name needs to be found based on
other criteria?
Thanks
Al
This discussion has been closed.
Comments
Try performing a report object loop to find specific components in your
report. See the following article as well as the sample RAP code below.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Layouts/Report_Object_Loop
var
liBand: Integer;
liObject: Integer;
lObject: TppComponent;
begin
for liBand := 0 to Report.BandCount-1 do
begin
for liObject := 0 to Report.Bands[liBand].ObjectCount-1 do
begin
lObject := Report.Bands[liBand].Objects[liObject];
if lObject.Name = 'ppLabel1' then
ShowMessage('Found!');
end;
end;
end;
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com