Glossary Item Box
ActiveReports allows you to apply a page template to an existing report by using the Overlay method.
This walkthrough illustrates how to overlay an ActiveReport with a "letterhead" page template.
This walkthrough is split up into the following activities:
To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).
When you have completed this walkthrough, you will have a report that looks similar to the following.
To add two ActiveReports to a Visual Studio project
To connect the report to a data source
To add controls to the reports
Control | DataField | Name | Text/Caption | Section | Location |
---|---|---|---|---|---|
Label | (Empty string) | lblCustomerID | Customer ID | GroupHeader | 0, 0 |
Label | (Empty string) | lblCompanyName | Company Name | GroupHeader | 1.125, 0 |
Label | (Empty string) | lblAddress | Address | GroupHeader | 2.625, 0 |
Label | (Empty string) | lblCity | City | GroupHeader | 4.125, 0 |
Label | (Empty string) | lblCountry | Country | GroupHeader | 5.187, 0 |
TextBox | CustomerID | txtCustomerID | Customer ID | Detail | 0, 0 |
TextBox | CompanyName | txtCompanyName | CompanyName | Detail | 1.125, 0 |
TextBox | Address | txtAddress | Address | Detail | 2.625, 0 |
TextBox | City | txtCity | City | Detail | 4.125, 0 |
TextBox | Country | txtCountry | Country | Detail | 5.187, 0 |
Control | Name | Text/Caption | Section | Location |
---|---|---|---|---|
TextBox | txtCompanyName | Company Name | PageHeader | 0.0625, 0.0625 |
Label | lblCompanyLogo | (Company Logo) | PageHeader | 4, 0.0625 |
Label | lblCompanyInfo | Company Address, Phone Number, Fax Number, URL | PageFooter | 0.0625, 0.0625 |
To write the code in Visual Basic
Right-click at the top of Form1, and click on View Code to display the code view for the form. At the top left of the code view for Form1, click the drop-down arrow and select (Base Class Events). At the top right of the code window, click the drop-down arrow and select Load. This creates an event-handling method for the Form1_Load event. Add code to the handler to:
To write the code in C#
Click at the top of Form1 to select the form. Click on the events icon in the Properties window to display available events for the form. Double-click Load. This creates an event-handling method for the Form1_Load event. Add code to the handler to:The following example shows what the code for the Overlay method looks like.
' Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _ MyBase.Load
Dim rpt As New rptReport()
rpt.Run() Dim rpt2 As New rptTemplate()
rpt2.Run()
Viewer1.Document = rpt.Document
For i = 0 To rpt.Document.Pages.Count - 1
rpt.Document.Pages(i).Overlay(rpt2.Document.Pages(0))
Next
End Sub
//C#
private void Form1_Load(object sender, System.EventArgs e)
{
rptReport rpt = new rptReport();
rpt.Run();
rptTemplate rpt2 = new rptTemplate();
rpt2.Run();
viewer1.Document = rpt.Document;
for(int i = 0; i < rpt.Document.Pages.Count; i++)
{
rpt.Document.Pages[i].Overlay(rpt2.Document.Pages[0]);
}
}
To view the report
See Also |
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.