You can create a base report class as a template from which other reports can inherit. This is useful when many of your reports share common features, such as identical page headers and footers. Instead of recreating the look every time, create template headers and footers once and use inheritance to apply them to your other reports.
In ActiveReports, you can use inheritance at both design time and run time. A simple example of how you can use this functionality is a company letterhead template.
Controls for rptLetterhead
Control | Section | Location | Size | Miscellaneous |
---|---|---|---|---|
Picture | PageHeader | 0, 0 in | 3, 0.65 in | Image = (click ellipsis, navigate to C:\Program Files\GrapeCity\ActiveReports 6\Introduction (or to C:\Program Files (x86)\GrapeCity\ActiveReports 6\Introduction on a 64-bit Windows operating system) and select itopimage1.gif) PictureAlignment = TopLeft |
Label | PageHeader | 0.75, 0.65 in | 1.2, 0.19 in | Text = Control Yourself! FontStyle = Bold |
Label | PageFooter | 0, 0 in | 6.5, 0.19 in |
Text = http://www.datadynamics.com HyperLink = http://www.datadynamics.com FontStyle = Bold Alignment = Center |
Important: Do not set the MasterReport property to True until you have finished making changes to the report. Setting this property to True triggers major changes in the designer file for the report. |
To write the code in Visual Basic.NET
Visual Basic.NET code. |
Copy Code |
---|---|
Partial Public Class rptLetter Inherits YourProjectName.rptLetterhead |
To write the code in C#
C# code. |
Copy Code |
---|---|
public partial class rptLetter : YourProjectName.rptLetterhead |
Note: To make changes in these sections in rptLetterhead and rebuild your project again. |
Add data and controls to the detail section of the report as you would any other report. See the Basic Data Bound Reports walkthrough for more information.
Caution: Base reports and the reports that inherit from them cannot contain controls with duplicate names. You can compile and run your project with duplicate control names, but you cannot save the layout until the duplicate names are changed. |