Simple dynamic report
Am trying to create dynamic subreports(Printbehaviour = pbSection)
and place labels, images etc within it. There are no dbcontrols or
pipelines attached to this report. There is the Main report and in
the Detailband of that is one DesignTime Subreport with a TppImage in
the TitleBand
What I've noticed in the designtime environment in the ReportDesigner
is that if I place objects within the Detailband and press Preview
report I do not see anything. I suspect this is because there are no
pipelines attached but am not sure.
Assuming I'll just use titlebands for my objects and I create a
subreport like this
ASub := TppSubreport.create(Self);
ASub.Band := DetailBand1;//The main report detailband
ASub.PrintBehavior := pbSection;//Each subreport gets own page
ASub.CreateReport(ppReport1);// ppReport1 is the Report Component
ASub.Report.DefaultBands := [btTitle];
ASub.Report.CreateDefaultBands;
ATitleBand := ASub.Report.GetBand(btTitle,0) as TppTitleBand;
AnImage := TppImage.Create(Self);
AnImage.Band := ATitleBand;
AnImage.Picture.LoadFromFile('ATeeChart.bmp');
AnImage.Top := 0.5;
AnImage.Left := 0.5;
ALabel := TppLabel.Create(Self);
ALabel.Band := ATitleBand;
ALabel.Caption := 'Im a label';
ALabel.Top := 0.5;
ALabel.Left := 1.5;
When I Run this application I expect to see 3 pages. The Main report
page, the Design time subreport and my dynamic subreport. What I get
is the first two and my dynamic report preview is a blank.
Advice most welcome.
Dale
and place labels, images etc within it. There are no dbcontrols or
pipelines attached to this report. There is the Main report and in
the Detailband of that is one DesignTime Subreport with a TppImage in
the TitleBand
What I've noticed in the designtime environment in the ReportDesigner
is that if I place objects within the Detailband and press Preview
report I do not see anything. I suspect this is because there are no
pipelines attached but am not sure.
Assuming I'll just use titlebands for my objects and I create a
subreport like this
ASub := TppSubreport.create(Self);
ASub.Band := DetailBand1;//The main report detailband
ASub.PrintBehavior := pbSection;//Each subreport gets own page
ASub.CreateReport(ppReport1);// ppReport1 is the Report Component
ASub.Report.DefaultBands := [btTitle];
ASub.Report.CreateDefaultBands;
ATitleBand := ASub.Report.GetBand(btTitle,0) as TppTitleBand;
AnImage := TppImage.Create(Self);
AnImage.Band := ATitleBand;
AnImage.Picture.LoadFromFile('ATeeChart.bmp');
AnImage.Top := 0.5;
AnImage.Left := 0.5;
ALabel := TppLabel.Create(Self);
ALabel.Band := ATitleBand;
ALabel.Caption := 'Im a label';
ALabel.Top := 0.5;
ALabel.Left := 1.5;
When I Run this application I expect to see 3 pages. The Main report
page, the Design time subreport and my dynamic subreport. What I get
is the first two and my dynamic report preview is a blank.
Advice most welcome.
Dale
This discussion has been closed.
Comments
The first thing I see is that the size of the subreport, image and label are
not set. Also, try using the autosize property of the label too. Everything
else looks ok, such as assigning the band property which is correct. Here is
an example of creating a subreport in code in case you find any other
differences:
http://www.digital-metaphors.com/tips/DynamicSubreportCreation.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com