Skip to main content

Implement a Custom Parameter Editor in WinForms Applications

  • 2 minutes to read

You can use BaseEdit descendants as custom parameter editors in the Parameters panel.

Important

Customization options described in this help topic are available to owners of DevExpress WinForms, DXperience, and Universal subscriptions (subscriptions that include DevExpress WinForms UI Controls). The DevExpress Reporting Subscription does not support UI customization in Report Viewer or End-User Report Designer. You can use ReportPrintTool and ReportDesignTool classes to display Print Preview and End-User Report Designer in their default configurations.

Refer to the following help topic for information on subscription options: Installation - Subscriptions that Include Reporting Components.

To use a custom editor, do the following:

To resize a custom parameter editor, use the editor’s MinimumSize and MaximumSize properties.

Example

The following code snippet replaces the parameter editor with a radio group.

Custom parameter editor

View Example: Implement a Custom Parameter Editor (WinForms)

using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraReports.Parameters;
// ...
private void XtraReport1_ParametersRequestBeforeShow(object sender, ParametersRequestEventArgs e) {
    // Create and set up a radio group editor.
    var radioGroup = CreateRadioGroup();

    // Find a required parameter by name and assign
    // a custom editor to the Editor property.
    foreach (var info in e.ParametersInformation) {
        if (info.Parameter.Name == "shape") {
            info.Editor = radioGroup;
            break;
        }
    }
}

private RadioGroup CreateRadioGroup() {
    var radioGroup = new RadioGroup();

    string[] radioGroupItemTitles = new string[] {
        "Circle", "Rectangle", "Ellipse",
        "Triangle", "Square"
    };

    foreach (var item in radioGroupItemTitles) {
        radioGroup.Properties.Items.Add(new RadioGroupItem(item, item));
    }

    radioGroup.Properties.ItemVertAlignment = RadioItemVertAlignment.Top;
    radioGroup.MinimumSize = new System.Drawing.Size(0, 100);

    return radioGroup;
}
See Also