Skip to main content

How to: Register an Additional Type of XtraReport Parameter

This example demonstrates how to extend the list of parameter types available in the Report Designer.

In this topic, it is assumed that you have an XAF application that uses the Reports V2 Module, and you have created one or more reports (see Reports V2 Module Overview).

  1. Handle the static ReportDesignExtensionManager.CustomizeReportExtension event to access an XtraReportDataTypeProvider instance.
  2. Handle the XtraReportDataTypeProvider.CustomAddParameterTypes event to add custom types to the Dictionary list.
  3. Handle the XtraReportDataTypeProvider.GetCustomEditableDataTypes event to add custom types to the Types array.

The following code snippet illustrates how to add the Gender enumeration type.

using DevExpress.ExpressApp.ReportsV2;
// ...
static class Program {
    static void Main() {
        ReportDesignExtensionManager.CustomizeReportExtension += ReportDesignExtensionManager_CustomizeReportExtension;
        // ...
    }
    static void ReportDesignExtensionManager_CustomizeReportExtension(object sender, CustomizeReportExtensionEventArgs e) {
        e.XafReportDataTypeProvider.CustomAddParameterTypes += XafReportDataTypeProvider_CustomAddParameterTypes;
        e.XafReportDataTypeProvider.GetCustomEditableDataTypes += XafReportDataTypeProvider_GetCustomEditableDataTypes;
    }
    static void XafReportDataTypeProvider_CustomAddParameterTypes(object sender, AddCustomParameterTypesEventArgs e) {
        e.Dictionary.Add(typeof(Gender), "Gender");
    }
    static void XafReportDataTypeProvider_GetCustomEditableDataTypes(object sender, GetCustomEditableDataTypesEventArgs e) {
        List<Type> types = new List<Type>(e.Types);
        types.Add(typeof(Gender));
        e.Types = types.ToArray();
    }
    // ...
}
public enum Gender { Male, Female}

The result is demonstrated in the image below.

ReportsV2_CustomAddParameterTypes