Home Subreports

How to create a subreport in the main report dynamically

Delphi xe2 and ReprotBuilder ver 15
my requirement is to create some subreports on the main report detail band;
I have some problems dealing with RB components and events;
the subreport is loaded from rtm file.
Because the subreport is created dynamically,
so the event always not working.
For example. myRep1.rtm file is based on a report AReprot(TppReprot) and it is designed by hand.
it contains a headerband event, and some detailed subreports;
procedure TForm1.ppHeaderBand1BeforePrint(Sender: TObject);
on run time.
I create a subreport by code as below:
//ppReport3 is the main report as a container for subreports, it has detailband(ppDetailBand9) only;
mySubReport := TppSubReport.Create(Self);
mySubReport.CreateReport(ppReport3);
mySubReport.Band := ppDetailBand9;//;//
mySubReport.Report.Template.FileName := HomePath + 'myRep1.rtm';
mySubReport.Report.Template.LoadFromFile;
mySubReport.PrintBehavior := pbsection;
Run ppReport3.print , it will not trig the .ppHeaderBand1BeforePrint event,
I think it is right because the mySuReport haderband is not named ppherBand1.
the most difficult part is how to find out the real target componet's name.
and set its event point procedure up properly;
another problem is on the report designer window, the name of the component does not match on the Delphi Ide object list, it confuses me, and wonder how to assign value to the component properly.
I do not find a demo for my requirement.
Could you guide me on the right way to create a subreport in the main report dynamically.
Thanks


Sign In or Register to comment.