windowsforms-devexpress-dot-xtraeditors-dot-filtercontrol-be8c9bbd.md
Allows you to assign a custom editor used to display and edit an operand.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Events")]
public event EventHandler<CustomValueEditorArgs> CustomValueEditor
<DXCategory("Events")>
Public Event CustomValueEditor As EventHandler(Of CustomValueEditorArgs)
The CustomValueEditor event's data class is CustomValueEditorArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| ElementIndex | |
| Node | |
| Operation | |
| PropertyName | Gets the name of the current property (column/field). Inherited from BaseNodeEventArgs. |
| PropertyType | Gets the type of the current property (column/field). Inherited from BaseNodeEventArgs. |
| RepositoryItem | |
| Value |
The CustomValueEditor event fires before the Filter Control displays a value operand. Handle this event to specify a custom editor used to display and edit the operand. For this purpose, create a corresponding repository item (a RepositoryItem descendant) and assign it to the RepositoryItem event parameter.
The FilterControl.CustomValueEditorForEditing event allows you to specify an editor that is only used to edit an operand.
This example handles the FilterControl.CustomValueEditor event to assign custom editors (Spin Editor and Calc Editor) to value operands in Data Grid’s embedded FilterControl.
The Data Grid’s ColumnView.FilterEditorCreated event is used to subscribe to the FilterControl.CustomValueEditor event.
private void gridView1_FilterEditorCreated(object sender, FilterControlEventArgs e) {
e.FilterEditor.CustomValueEditor += FilterEditor_CustomValueEditor;
}
readonly RepositoryItemSpinEdit spinEdit = new RepositoryItemSpinEdit();
readonly RepositoryItemCalcEdit calcEdit = new RepositoryItemCalcEdit();
private void FilterEditor_CustomValueEditor(object sender, CustomValueEditorArgs e) {
if (e.Node.FirstOperand.PropertyName != "Payment") return;
RepositoryItemTextEdit item = null;
if (e.ElementIndex == 2)
item = spinEdit;
else
item = calcEdit;
var settings = item.MaskSettings.Configure<MaskSettings.Numeric>();
settings.MaskExpression = "c";
e.RepositoryItem = item;
}
Private Sub gridView1_FilterEditorCreated(ByVal sender As Object, ByVal e As FilterControlEventArgs) Handles gridView1.FilterEditorCreated
AddHandler e.FilterControl.CustomValueEditor, AddressOf FilterControl_CustomValueEditor
End Sub
Private ReadOnly spinEdit As New RepositoryItemSpinEdit()
Private ReadOnly calcEdit As New RepositoryItemCalcEdit()
Private Sub FilterControl_CustomValueEditor(ByVal sender As Object, ByVal e As CustomValueEditorArgs)
If e.Node.FirstOperand.PropertyName <> "Payment" Then
Return
End If
Dim item As RepositoryItemTextEdit = Nothing
If e.ElementIndex = 2 Then
item = spinEdit
Else
item = calcEdit
End If
Dim settings As MaskSettings.Numeric = item.MaskSettings.Configure(Of MaskSettings.Numeric)()
settings.MaskExpression = "c"
e.RepositoryItem = item
End Sub
See Also