Skip to main content

Create Predefined Static Reports

  • 4 minutes to read

This topic describes how you can create an XtraReport at Design Time and then register it. Registered reports will be added to the Reports List View in the application. These predefined reports cannot be modified by a user. However, a user can copy a predefined report using the Copy Predefined Report Action, and then modify the copy. Follow the steps below to create an XtraReport and register it for use with the Reports V2 module.

  1. Add an empty XtraReport to your module project using the DevExpress v.22.1 Report project item template (see Report Wizard). Select Blank and click Finish.


  2. The Data Source components that can be used in XAF-compatible XtraReport classes are CollectionDataSource and ViewDataSource. Other data sources are not supported by Reports V2. These components are available in the DX.22.1: XAF Data Sources for Reports (.NET Framework)/DX: Report Controls (.NET 6, .NET Standard) group of the Visual Studio Toolbox. Drag the CollectionDataSource component from the Toolbox to the created report.



    You can use the ViewDataSource component instead of the CollectionDataSource. The difference between these components is described in the Data Sources for Reports V2 topic.

  3. In the Properties window, set the ObjectTypeName property of the CollectionDataSource component to the name of the business class that will be displayed in your report. As a result, business class properties will be added to the Field List window.


  4. Drag the required fields to the report, or run the Report Wizard to generate a required markup automatically.


    To learn more about report design, refer to Reporting documentation (see Report Designer and Report Wizard). Note that the CollectionDataSource and ViewDataSource components do not provide actual data to the designer. They provide only a list of fields. This is why you cannot preview the report at design time.


    • At design time, the Preview tab of the Report Designer is empty. The CollectionDataSource and ViewDataSource components do not connect to a database directly and require an IObjectSpace instance (that can be created at runtime only) to load data. Thus, it cannot load data at design time.

    • Currently, Custom Fields are not available in the Reports Designer at design time.
  5. After the report is saved, register it within your XAF application. Instantiate the PredefinedReportsUpdater class and add a report using the PredefinedReportsUpdater.AddPredefinedReport<T> method. Then, modify the module’s ModuleBase.GetModuleUpdaters method and add the PredefinedReportsUpdater object to the resulting array of this method (initially, this array contains the single default updater). To do this, edit the Module.cs (Module.vb) file as shown below.

    using DevExpress.ExpressApp.ReportsV2;
    // ...
    public override IEnumerable<ModuleUpdater> GetModuleUpdaters(
        IObjectSpace objectSpace, Version versionFromDB) {
        ModuleUpdater updater = new DatabaseUpdate.Updater(objectSpace, versionFromDB);
        PredefinedReportsUpdater predefinedReportsUpdater = 
            new PredefinedReportsUpdater(Application, objectSpace, versionFromDB);
        predefinedReportsUpdater.AddPredefinedReport<XtraReport1>("Contacts Report", typeof(Contact));
        return new ModuleUpdater[] { updater, predefinedReportsUpdater };


    By default, each new PredefinedReportsUpdater instance removes predefined reports that are not registered within this instance. If you implement your reports in several modules and need to create multiple PredefinedReportsUpdater objects in a single application, set the PredefinedReportsUpdater.UseMultipleUpdaters property of each updater to true.

Run the application. Note that the designed XtraReport is available in the Reports List View. A user can double-click a report to preview it in a Print Preview Form.


If you want to skip the preview dialog, refer to the How to: Print a Report Without Displaying a Preview example.


When you create a predefined report with scripts that will possibly be modified by end-users, do not use XtraReport events directly. Instead, use the XtraReport.Scripts and/or XRControl.Scripts properties in the Report Designer, as demonstrated in the Scripting Overview topic. Otherwise, your code will not be copied to user scripts using the Copy Predefined Report Action. If you use this approach, add references to assemblies used in scripts to the XtraReport.ScriptReferences property. Assemblies used in your application will be attached to scripts automatically. If classes from such assemblies cause errors when scripts are evaluated, either use fully qualified names, or add the using (Imports in VB) directive at the beginning of the script.