xtrareports-5110-desktop-reporting-winforms-reporting-winforms-reporting-print-preview-api-and-customization-implement-custom-parameter-editor.md
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.
The following code snippet replaces the parameter editor with a radio group.
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;
}
Imports DevExpress.XtraEditors
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraReports.Parameters
' ...
Private Sub XtraReport1_ParametersRequestBeforeShow(ByVal sender As Object, ByVal e As ParametersRequestEventArgs) Handles MyBase.ParametersRequestBeforeShow
' Create and set up a radio group editor.
Dim radioGroup = CreateRadioGroup()
' Find a required parameter by name and assign
' a custom editor to the Editor property.
For Each info In e.ParametersInformation
If info.Parameter.Name = "shape" Then
info.Editor = radioGroup
Exit For
End If
Next info
End Sub
Private Function CreateRadioGroup() As RadioGroup
Dim radioGroup = New RadioGroup()
Dim radioGroupItemTitles() As String = {"Circle", "Rectangle", "Ellipse", "Triangle", "Square"}
For Each item In radioGroupItemTitles
radioGroup.Properties.Items.Add(New RadioGroupItem(item, item))
Next item
radioGroup.Properties.ItemVertAlignment = RadioItemVertAlignment.Top
radioGroup.MinimumSize = New System.Drawing.Size(0, 100)
Return radioGroup
End Function
See Also