create dynamic report problem
I try to create a dynamic report. I've declared a class for my fastreport in Delphi:
TF_Report = class
private
FReport : TfrxReport;
FDataPage: TfrxDataPage;
FPage: TfrxReportPage;
FTitleBand: TfrxBand;
FHeadBand :TfrxColumnHeader;
FDataBand: TfrxMasterData;
FFont: TFont;
FMemo: TfrxMemoView;
FHMemo: TfrxMemoView;
FDMemo: TfrxMemoView;
public
constructor Create(AOwner: TComponent);
destructor Destroy;
function CreateItems(dbsGrid: TADBGrid; Index: Integer): Integer;
procedure DestroyItems;
end;
var
FR_General: TF_Report;
here is the constructor method to create the fastreport object:
constructor TF_Report.Create(AOwner: TComponent);
begin
DM_Resource.frxDBDataset1.DataSet := Frm_Report_General.Report; //Report is a query
FReport := TFrxReport.Create(AOwner);
FReport.DataSets.Add(DM_Resource.frxDBDataSet1); //I've placed a frxDBDataset on my form
FDataPage := TfrxDataPage.Create(FReport);
FPage := TfrxReportPage.Create(FReport);
FPage.CreateUniqueName;
FPage.SetDefaults;
FPage.Orientation := poLandscape;
FTitleBand := TfrxReportTitle.Create(FPage);
FTitleBand.CreateUniqueName;
FTitleBand.Top := 16;
FTitleBand.Height := 60;
{ add an object to the report title band }
FMemo := TfrxMemoView.Create(FTitleBand);
FMemo.CreateUniqueName;
FMemo.Text := QuotedStr('Test');
FMemo.Height := 20;
FMemo.Align := baWidth;
{ add the masterdata band }
FHeadBand := TfrxColumnHeader.Create(FPage);
FHeadBand.CreateUniqueName;
FHeadBand.Top := 96;
FHeadBand.Height := 30;
FDataBand := TfrxMasterData.Create(FPage);
FDataBand.CreateUniqueName;
FDataBand.DataSet := DM_Resource.frxDBDataSet1;
FDataBand.Top := 184;
FDataBand.Height := 30;
fdMemo := TfrxMemoView.Create(fDataBand);
fdMemo.CreateUniqueName;
FDMemo.Text := QuotedStr('hi');
FReport.ShowReport();
end;
I can see the titleband with the memo but my databand is not created. please help me. tanx.
TF_Report = class
private
FReport : TfrxReport;
FDataPage: TfrxDataPage;
FPage: TfrxReportPage;
FTitleBand: TfrxBand;
FHeadBand :TfrxColumnHeader;
FDataBand: TfrxMasterData;
FFont: TFont;
FMemo: TfrxMemoView;
FHMemo: TfrxMemoView;
FDMemo: TfrxMemoView;
public
constructor Create(AOwner: TComponent);
destructor Destroy;
function CreateItems(dbsGrid: TADBGrid; Index: Integer): Integer;
procedure DestroyItems;
end;
var
FR_General: TF_Report;
here is the constructor method to create the fastreport object:
constructor TF_Report.Create(AOwner: TComponent);
begin
DM_Resource.frxDBDataset1.DataSet := Frm_Report_General.Report; //Report is a query
FReport := TFrxReport.Create(AOwner);
FReport.DataSets.Add(DM_Resource.frxDBDataSet1); //I've placed a frxDBDataset on my form
FDataPage := TfrxDataPage.Create(FReport);
FPage := TfrxReportPage.Create(FReport);
FPage.CreateUniqueName;
FPage.SetDefaults;
FPage.Orientation := poLandscape;
FTitleBand := TfrxReportTitle.Create(FPage);
FTitleBand.CreateUniqueName;
FTitleBand.Top := 16;
FTitleBand.Height := 60;
{ add an object to the report title band }
FMemo := TfrxMemoView.Create(FTitleBand);
FMemo.CreateUniqueName;
FMemo.Text := QuotedStr('Test');
FMemo.Height := 20;
FMemo.Align := baWidth;
{ add the masterdata band }
FHeadBand := TfrxColumnHeader.Create(FPage);
FHeadBand.CreateUniqueName;
FHeadBand.Top := 96;
FHeadBand.Height := 30;
FDataBand := TfrxMasterData.Create(FPage);
FDataBand.CreateUniqueName;
FDataBand.DataSet := DM_Resource.frxDBDataSet1;
FDataBand.Top := 184;
FDataBand.Height := 30;
fdMemo := TfrxMemoView.Create(fDataBand);
fdMemo.CreateUniqueName;
FDMemo.Text := QuotedStr('hi');
FReport.ShowReport();
end;
I can see the titleband with the memo but my databand is not created. please help me. tanx.
Comments