Back to Devexpress

FilterControl.CustomValueEditor Event

windowsforms-devexpress-dot-xtraeditors-dot-filtercontrol-be8c9bbd.md

latest5.0 KB
Original Source

FilterControl.CustomValueEditor Event

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

Declaration

csharp
[DXCategory("Events")]
public event EventHandler<CustomValueEditorArgs> CustomValueEditor
vb
<DXCategory("Events")>
Public Event CustomValueEditor As EventHandler(Of CustomValueEditorArgs)

Event Data

The CustomValueEditor event's data class is CustomValueEditorArgs. The following properties provide information specific to this event:

PropertyDescription
ElementIndex
Node
Operation
PropertyNameGets the name of the current property (column/field). Inherited from BaseNodeEventArgs.
PropertyTypeGets the type of the current property (column/field). Inherited from BaseNodeEventArgs.
RepositoryItem
Value

Remarks

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.

Example

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.

csharp
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;
}
vb
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

FilterControl Class

FilterControl Members

DevExpress.XtraEditors Namespace