Using Subreports and regions
Hello,
I have a report with subreports and these subreports have own subreports,
too. To show the beginnings and ends of the different subreports I
created a region in every detailband with 'ParentWidth' and
'ParentHeight' = true and set the 'pen.Style' property to psSolid.
Here is the code:
function CreateNewReport(ReportToFill : TppBandedReport) : TppSubReport;
var
NewChildReport: TppChildReport;
OldReport : TppSubReport;
TempReport : TppStretchable;
NewRegion: TppRegion;
begin
Result := TppSubReport(ppComponentCreate(GroupReport, Tppsubreport));
Result.Band := ReportToFill.DetailBand;
Result.CreateReport(MainReport.Report);
//MainReport is a TppReport, lying on my form
Result.ParentWidth := true;
NewChildReport := TppChildReport(Result.Report);
NewChildReport.CreateDefaultBands;
NewChildReport.TitleBand.Visible := false;
NewChildReport.DetailBand.PrintHeight := phDynamic;
NewChildReport.SummaryBand.Visible := false;
NewChildReport.DetailBand.BottomOffset := 2;
//the 'Frame' I create
with TppRegion(ppComponentCreate(GroupReport, TppRegion)) do
begin
Band:=NewChildReport.DetailBand;
ParentWidth := True;
ParentHeight := true;
Pen.Color := clNavy;
Pen.Style:=psSolid;
Visible:=True;
end;
if something then
begin //Create a new subreport
TempReport := DrawGroupIntoReport(NewChildreport);
end
else
begin
TempReport:=TppRegion(ppComponentCreate(MainReport,
TppRegion));
with TppRegion(TempReport) do
begin
Band:=NewChildReport.DetailBand;
ParentWidth:=True;
Pen.Style:=psClear;
Stretch:=True;
Visible:=True;
Transparent := true;
end;
for j := 1 to 3 do
for k := 0 to FieldList.Count - 1 do
begin
with TppLabel(ppComponentCreate(NewChildReport,
TppLabel)) do
begin
//Band := NewChildReport.DetailBand;
Region := TppRegion(TempReport);
Transparent := true;
Font.Size := 12;
Left := k * FieldWidth;
Top := (j - 1) * Height;
Caption := 'XXX';
Visible := true;
NewTop := trunc(Top + Height);
end;
end;
end;
end;
Can you help me to find the mistake??
Thank you
Christine
I have a report with subreports and these subreports have own subreports,
too. To show the beginnings and ends of the different subreports I
created a region in every detailband with 'ParentWidth' and
'ParentHeight' = true and set the 'pen.Style' property to psSolid.
Here is the code:
function CreateNewReport(ReportToFill : TppBandedReport) : TppSubReport;
var
NewChildReport: TppChildReport;
OldReport : TppSubReport;
TempReport : TppStretchable;
NewRegion: TppRegion;
begin
Result := TppSubReport(ppComponentCreate(GroupReport, Tppsubreport));
Result.Band := ReportToFill.DetailBand;
Result.CreateReport(MainReport.Report);
//MainReport is a TppReport, lying on my form
Result.ParentWidth := true;
NewChildReport := TppChildReport(Result.Report);
NewChildReport.CreateDefaultBands;
NewChildReport.TitleBand.Visible := false;
NewChildReport.DetailBand.PrintHeight := phDynamic;
NewChildReport.SummaryBand.Visible := false;
NewChildReport.DetailBand.BottomOffset := 2;
//the 'Frame' I create
with TppRegion(ppComponentCreate(GroupReport, TppRegion)) do
begin
Band:=NewChildReport.DetailBand;
ParentWidth := True;
ParentHeight := true;
Pen.Color := clNavy;
Pen.Style:=psSolid;
Visible:=True;
end;
if something then
begin //Create a new subreport
TempReport := DrawGroupIntoReport(NewChildreport);
end
else
begin
TempReport:=TppRegion(ppComponentCreate(MainReport,
TppRegion));
with TppRegion(TempReport) do
begin
Band:=NewChildReport.DetailBand;
ParentWidth:=True;
Pen.Style:=psClear;
Stretch:=True;
Visible:=True;
Transparent := true;
end;
for j := 1 to 3 do
for k := 0 to FieldList.Count - 1 do
begin
with TppLabel(ppComponentCreate(NewChildReport,
TppLabel)) do
begin
//Band := NewChildReport.DetailBand;
Region := TppRegion(TempReport);
Transparent := true;
Font.Size := 12;
Left := k * FieldWidth;
Top := (j - 1) * Height;
Caption := 'XXX';
Visible := true;
NewTop := trunc(Top + Height);
end;
end;
end;
end;
Can you help me to find the mistake??
Thank you
Christine
This discussion has been closed.
Comments
you forgot to describe your problem.
regards,
Chris Ueberall;
http://www.digital-metaphors.com/tips/DynamicSubreportCreation.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
My problem was, taht the frame wasn't printed to the report. I've found a
solution my own.
Thanks
Christine