Accessing report objects from code

Top  Previous  Next

FastReport’s objects (report page, band, memo object, etc.) are not directly accessible from your code. This means that you cannot address an object directly by its name, as for example when addressing a button on your form. To address an object it should be first be found using the “TfrxReport.FindObject” method:

 

Pascal:

 

var

 Memo1: TfrxMemoView;

 

Memo1 := frxReport1.FindObject('Memo1') as TfrxMemoView;

 

C++:

 

TfrxMemoView * Memo = dynamic_cast <TfrxMemoView *>

                        (frxReport1->FindObject("Memo1"));

 

Once found the object’s properties and methods can be accessed.

 

You can address the report’s pages using the “TfrxReport.Pages” property:

 

Pascal:

 

var

 Page1: TfrxReportPage;

 

Page1 := frxReport1.Pages[1] as TfrxReportPage;

 

C++:

 

TfrxReportPage * Page1 = dynamic_cast <TfrxReportPage *>

                          (frxReport1->Pages[1]);