Embedded Reports (Loaded at Design Time)
Under this scenario, an application generates reports using a fixed set of report definitions that are built into the application. This type of application does not rely on any external report definition files, and end-users have no way to modify the reports.
The main advantage of this type of application is that you don't need to distribute the report definition file, and you can be sure that no one will modify the report format. The disadvantage is that to make any modifications to the report, you must recompile the application.
If you want to use a report definition that you already have, without any modifications, follow these steps (we will later describe how you can edit an embedded report or create one from scratch):
1. Add one C1Report component for each report definition you want to distribute. You may want to name each control after the report it will render (this will make your code easier to maintain).
2. Right-click each C1Report component and select the Load Report menu option to load report definitions into each control. (You can also click the smart tag () above the component to open the C1Report Tasks menu.)
The Select a report dialog box appears, which allows you to select a report definition file and then a report within that file.
To load a report, click the ellipsis button to select the report definition file you created in step 1, then select the report from the drop-down list and click the Load button. The property page shows the name of the report you selected and a count of groups, sections, and fields. This is what the dialog box looks like:
3. Add a single C1PrintPreview control to the form (or a Microsoft PrintPreviewControl) and also add a control that will allow the user to pick a report (this could be a menu, a list box, or a group of buttons).
4. Add code to render the report selected by the user. For example, if you added a button in the previous step with the name btnProductsReport, the code would look like this:
Private Sub btnProductsReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProductsReport.Click
ppv.Document = rptProducts.Document
End Sub
• C#
private void btnProductsReport_Click(object sender, System.EventArgs e)
{
ppv.Document = rptProducts.Document;
}
Note that rptProducts is the name of the C1Report component that contains the report selected by the user and ppv is the name of the C1PrintPreview control.
|