Dynamic Objects runtime
Hi everybody.
I'm trying to create somw BarCode runtime so I wrote like this:
rpt_dyn_barCode:= TfrxBarCodeView.Create(rpt_report);
rpt_dyn_barCode.CreateUniqueName;
rpt_dyn_barCode.Left := 3;
rpt_dyn_barCode.Top := 3;
rpt_dyn_barCode.Width := 3;
rpt_dyn_barCode.Height := 1;
rpt_dyn_barCode.Zoom := 1;
rpt_dyn_barCode.Rotation := 0;
rpt_dyn_barCode.BarCode.Text := '12345678';
rpt_dyn_barCode.Visible := true;
When I show my report I can't see the new BarCode.
Have You got any ideas about it?
Thanks
Bye
I'm trying to create somw BarCode runtime so I wrote like this:
rpt_dyn_barCode:= TfrxBarCodeView.Create(rpt_report);
rpt_dyn_barCode.CreateUniqueName;
rpt_dyn_barCode.Left := 3;
rpt_dyn_barCode.Top := 3;
rpt_dyn_barCode.Width := 3;
rpt_dyn_barCode.Height := 1;
rpt_dyn_barCode.Zoom := 1;
rpt_dyn_barCode.Rotation := 0;
rpt_dyn_barCode.BarCode.Text := '12345678';
rpt_dyn_barCode.Visible := true;
When I show my report I can't see the new BarCode.
Have You got any ideas about it?
Thanks
Bye
Comments
I only use this object from code... I don't need to connect to database...
Is It possible?
Maybe It's for this reason that I don't see the dynamic BarCode?
read the programmers manual about creating reports from code
Do You mean that I have to create object in the report?
On the beforePrint of some elements of the reports (maybe on PagebeforePrint)?
Thanks a lot
look at the sanple code from the manual
var
DataPage: TfrxDataPage;
Page: TfrxReportPage;
Band: TfrxBand;
DataBand: TfrxMasterData;
Memo: TfrxMemoView;
{ clear a report }
frxReport1.Clear;
{ add a dataset to the list of ones accessible for a report }
frxReport1.DataSets.Add(frxDBDataSet1);
{ add the "Data" page }
DataPage := TfrxDataPage.Create(frxReport1);
{ add a page }
Page := TfrxReportPage.Create(frxReport1);
//Note the design page was created in the context of the report.
{ create a unique name }
Page.CreateUniqueName;
{ set sizes of fields, paper and orientation by default }
Page.SetDefaults;
{ modify paper???s orientation }
Page.Orientation := poLandscape;
{ add a report title band}
Band := TfrxReportTitle.Create(Page);
// note the band was created in the context of the page
Band.CreateUniqueName;
{ it is sufficient to set the ?«Top?» coordinate and height for a band }
{ both coordinates are in pixels }
Band.Top := 0;
Band.Height := 20;
your barcode should be created in the context of a design page or a band.
I write this code as You said but I don't see any CodeBar...
only empty report...
procedure Tfrm_main.rpt_reportBeforePrint(Sender: TfrxReportComponent);
var
rpt_page: TfrxReportPage ;
rpt_band: TfrxBand;
rpt_dyn_barCode: TfrxBarCodeView;
begin
rpt_report.Clear;
rpt_page := TfrxReportPage.Create(rpt_report);
rpt_page.CreateUniqueName;
rpt_page.SetDefaults;
rpt_band := TfrxReportTitle.Create(rpt_page);
rpt_band.CreateUniqueName;
rpt_band.Top := 0;
rpt_band.Height := 20;
rpt_dyn_barCode:= TfrxBarCodeView.Create(rpt_band);
rpt_dyn_barCode.CreateUniqueName;
rpt_dyn_barCode.Left := 3;
rpt_dyn_barCode.Top := 3;
rpt_dyn_barCode.Width := 3;
rpt_dyn_barCode.Height := 1;
rpt_dyn_barCode.Zoom := 1;
rpt_dyn_barCode.Rotation := 0;
rpt_dyn_barCode.BarCode.Text := '12345678';
rpt_dyn_barCode.Visible := true;
end;
2nd may be the event you are trying to work in
look at this sample
code
procedure TForm1.Button1Click(Sender: TObject);
var
rpt_report:tfrxreport;
rpt_datapage:tfrxdatapage;
rpt_page: TfrxReportPage ;
rpt_band: TfrxBand;
rpt_dyn_barCode: TfrxBarCodeView;
begin
rpt_report:=frxreport1;
rpt_report.Clear;
rpt_datapage:=tfrxdatapage.Create(rpt_report);
rpt_page := TfrxReportPage.Create(rpt_report);
rpt_page.CreateUniqueName;
rpt_page.SetDefaults;
rpt_band := TfrxReportTitle.Create(rpt_page);
rpt_band.CreateUniqueName;
rpt_band.Top := 0;
rpt_band.Height := 20;
rpt_dyn_barCode:= TfrxBarCodeView.Create(rpt_band);
rpt_dyn_barCode.CreateUniqueName;
rpt_dyn_barCode.Left := 3;
rpt_dyn_barCode.Top := 3;
rpt_dyn_barCode.Width := 3;
rpt_dyn_barCode.Height := 10;// note the size change
rpt_dyn_barCode.Zoom := 1;
rpt_dyn_barCode.Rotation := 0;
rpt_dyn_barCode.BarCode.Text := '12345678';
rpt_dyn_barCode.Visible := true;
rpt_report.designreport; // call design to see what you have designed
end;
It was the height...
Many thanks
Bye