This sample explains the method to inherit a report at runtime and design time. The Inheritance sample solution comprises of two classes - the parent class and the child class for both inheritance at runtime and design time.
Sample Location
Visual Basic.NET
<User Folder>\ComponentOne Samples\ActiveReports 8\Section Reports\VB.NET\Layout\Inheritance
C#
<User Folder>\ComponentOne Samples\ActiveReports 8\Section Reports\C#\Layout\Inheritance
Runtime Features
When you run the sample, the report is created and displayed, providing you with the choice of two options - Inheritance Report created at RunTime and Inheritance Report created at Design Time. By clicking a button on the form, you get a report that inherits another class at runtime or at design time.
Inheritance Report created at RunTime
The rptInheritBase class is the inheritance class for the generated report when the Inheritance Report created at RunTime button is clicked on the form. The rptInheritBase class inherits the SectionReport class of the GrapeCity.ActiveReports namespace as parent class. It is possible to use DataInitialize event or FetchData event in this class and also possible to load csv file and set values for csv files. It defines the CsvPath property which gets csv file path.
The rptInheritChild class inherits the rptInheritBase class and is a class which only defines the report design. By adding the event handler for inheritance in the constructor and setting for csv file in CsvPath property, it is possible to perform rendering of data executed by event of BaseReport which is the inheritance class.
Inheritance Report created at Design Time
The rptDesignBase class is the inheritance class for the generated report when the Inheritance Report created at Design Time button is clicked on the form. The rptDesignBase class inherits SectionReport class of the GrapeCity.ActiveReports namespace as parent class. Using this class, you can place any control (ReportInfo controls etc. to display report title, page number, page count) you wish to inherit in PageHeader section and PageFooter section. The rptDesignChild class is inherited from rptDesignBase class. It only defines the design of Detail section. PageHeader section and PageFooter section use the design of rptDesignBase class which is an inherited class. DataSource setting can be performed from rptDesignChild class.
|
Caution: If you have not run the project even once, an error occurs when you try to open the report designers of the inherited classes rptInheritChild or rptDesignChild from the solution explorer. In case this error occurs, Build the project once before opening the report. |
Project Details
ViewerForm
Creates an instance of specified report and display the report in Viewer control.
rptDesignBase
The rptDesignBase class that defines the layout of PageHeader section and PageFooter section.
rptDesignChild
The rptDesignChild designer defines the layout on Detail section and sets the value of DataField property of the controls placed in Detail section. Also set the data source to output using Report Data Source dialog.
rptInheritBase
The class to set values for data field and rendering of csv file using DataInitialize event FetchData event.
rptInheritChild
The designer that sets layout for each control and it's DataField property.
See Also