Windows Forms applications built via the eXpressApp Framework provide a powerful instrument to create reports. This instrument is based on the built-in XtraReports Suite that allows you to create, customize, preview and print reports easily. This topic explains the available approaches to work with reports in Windows Forms applications. To learn about the Reports functionality in Web Sites, refer to the Reports Module in ASP.NET Applications topic.
The Windows Forms Reports module adds references to the DevExpress.ExpressApp.Reports.v18.2 and DevExpress.ExpressApp.Reports.Win.v18.2 assemblies.
You can add this module to your Windows Forms module. For this purpose, invoke the Module Designer and drag ReportsWindowsFormsModule from the Toolbox to the RequiredModules panel. Alternatively, you can add this module to the Windows Forms application project. To do this, invoke the Application Designer and drag ReportsWindowsFormsModule from the Toolbox to the Modules panel. Do not forget to rebuild your solution after making changes in a Designer.
To create a report, use the New Action. Select the Report item in the Action's dropdown list. This will invoke the Report Wizard window. The Report Name and Data Type editors represent the corresponding properties of the ReportData object. The DataType property specifies the type of persistent objects that will be used as data sources for the new report. To provide the required type for this property's value source, apply the DefaultClassOptions or VisibleInReports attribute to the class declaration, or set true for the corresponding BOModel | <Class> node's VisibleInReports property.
Complete report creation by following the wizard's steps.
For a detailed overview of the Report Wizard, refer to the Report Wizard topic.
A new ReportData object will be created and the Report Designer will be invoked.
The Report Designer is used to form the actual content of the new report. This content is saved to the ReportData object's field.
To learn how to use the Report Designer, refer to the First Look at the Report Designer topic.
You can use a custom design form inherited from the XafXRDesignForm class. To do this, subscribe to the WinReportServiceController.CreateCustomDesignForm event and pass the custom design form as the e.DesignForm parameter.
Use the Field List window to design the report. It provides the properties of the business class, selected as a data source type. Drag required properties to one of the report's bands. The report will display values of these properties for all objects of the specified type.
You can also filter the report data source. To learn how to do this, refer to the Filter Report Data Source using XtraReports Parameters, Filter Report Data Source using the ParametersObjectType Property and Use Function Criteria Operators to Filter Report Data Source help topics.
All created reports are available in the ReportData List View. This View is displayed in the Main Window when the Reports item is selected in the navigation control. To customize a report, use one of the following approaches.
Select a report in the ReportData List View and press the ShowReportDesigner Action. This will invoke the Report Designer. All customizations will be saved to the ReportData object's field.
The ShowReportDesigner Action is contained in the Reports Controller. You can customize this Action's settings in code, accessing it via the Controller's ShowReportDesignerAction property. In the Application Model, this Action is defined via the ActionDesign | Actions | ShowReportDesigner node.
Select a report in the ReportData List View and click Edit. A Detail View for the selected report will be invoked. In this View, you will be able to customize all properties except for the DataType property, since it is only related to the report's content designed via the Report Designer.
Take note of the IsInplaceReport property. Set this property to true to make the report inplace. For details, refer to the Show Reports for Individual Views topic.
The EditReportController.Edit Action is contained in the EditReportController. You can customize the Action's settings in code, accessing it via the Controller's EditReportAction property. In the Application Model, this Action is defined via the ActionDesign | Actions | Edit node.
The Reports module provides the ExecuteReport Action, intended for previewing and printing the selected report. This Action invokes the Preview window that allows the following operations.
The following operations can be performed via the corresponding items on the Preview window's toolbar.
The ExecuteReport Action is contained in the Reports Controller. You can customize this Action's settings in code, accessing it via the Controller.Actions property. In the Application Model, this Action is defined via the ActionDesign | Actions | ExecuteReportAction node.
The ExecuteReport Action is also executed when an end-user double-clicks a report in the ReportData List View or presses ENTER when the required report is selected in this View. You can replace this behavior and provide a custom Action to be executed. For details, refer to the second section of the How to: Replace a List View's Default Action topic.
You can also display a report from a custom Controller via the ReportServiceController's ShowPreview method. To do this, use the following code.
Where Object is a report implementing the IReportData interface.
You can show a report for a Detail View's current object or a List View's selected object(s). For this purpose, use the Inplace Reporting feature, provided by the Reports module.
To modify the ReportData class, perform the following steps.
Set your Report class for the ReportDataType property of the Reports Module. For this purpose, use the Properties window invoked with the Application Designer.
Alternatively, do it in code, in the Global.asax.cs (Global.asax.vb) or Program.cs (Program.vb) file. By default, the ReportDataType property is set to the ReportData type.
The Report Designer uses the ReportsModule.ReportDataType property to create a new persistent object or load an existing one from a database when designing an XtraReport. This aspect means that you can use the Report Designer to create and design XtraReport objects that will be stored using an object of the persistent type specified in the ReportModule.ReportDataType or its descendants. By default, the ReportData type is used. The ReportName property value is used to find a report in the database, so this property value should be unique to load a proper ReportData object.