Files to look at:
- Form1.cs (VB: Form1.vb)
- NorthwindDataProvider.cs (VB: NorthwindDataProvider.vb)
- Program.cs (VB: Program.vb)
This example illustrates how to create the simplest Master-Detail report by combining the Mail Merge feature with the DOCVARIABLE, RichEditControl.CalculateDocumentVariable and RichEditDocumentServer Class functionality. Three RichEditControl instances are used in this example. The first and the second controls contain master (Category) and detail (Product) templates correspondingly. The third control is used to display the resultant report.
The actual report generation implementation is pretty simple. When you press the "Create Report" button, master data rows from the first control are merged into the third control via the RichEditControl.MailMerge Method call. During this process, the CalculateDocumentVariable event is raised for the third control, because the master template (in the first control) contains a DOCVARIABLE field. Detail data rows from the second control are merged into a RichEditDocumentServer instance in this event handler. Finally, this instance is assigned to the e.Value parameter.
Both master and detail templates for this example are created by using Utility for creating a Mail Merge template.
To test this example locally, setup the sample "Northwind" database in your SQL Server instance by using the instnwind.sql file, attached with this example.
See Also:
How to use the Document.CalculateDocumentVariable event to insert a formatted content via the DOCVARIABLE field with a parameter
How to create a master-detail report in a RichEditControl