Back to Devexpress

ColumnView.FilterEditorCreated Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-07071b7a.md

latest8.3 KB
Original Source

ColumnView.FilterEditorCreated Event

Allows you to customize the Filter Editor before it is displayed on screen.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Behavior")]
public event FilterControlEventHandler FilterEditorCreated
vb
<DXCategory("Behavior")>
Public Event FilterEditorCreated As FilterControlEventHandler

Event Data

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

PropertyDescription
ContextProvides access to the ExpressionEditorContext object, which allows you to customize the FilterEditorControl‘s “Text” tab. Inherited from BaseFilterControlEventArgs.
FilterBuilderGets the form that displays the Filter Control.
FilterControlGets the Filter Control that displays filter criteria. This property returns null if the ColumnViewOptionsFilter.DefaultFilterEditorView property is set to any value except Visual.
FilterEditorGets the FilterControl (in Visual view mode) or embedded FilterControl (in VisualText, TextVisual and Text view modes). Inherited from BaseFilterControlEventArgs.
FilterEditorFormInherited from BaseFilterControlEventArgs.
IFilterControlGets the Filter Control that displays filter criteria.
IFilterEditorProvides access to the currently used Filter Control (FilterControl or FilterEditorControl) via an interface. Inherited from BaseFilterControlEventArgs.
ShowFilterEditorGets or sets whether to display the Filter Editor (the form that embeds the Filter Editor). Inherited from BaseFilterControlEventArgs.

Remarks

Use the FilterEditorCreated event to customize the Filter Editor, or prevent it from being displayed. The event fires each time the Filter Editor is to be displayed on screen.

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FilterEditorCreated event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

how-to-create-and-register-custom-filter-editor-functions/CS/DXApplication5/Main.cs#L17

csharp
gridView1.QueryCustomFunctions += OnQueryCustomFunctions;
gridView1.FilterEditorCreated += OnFilterEditorCreated;
gridView1.OptionsView.FilterCriteriaDisplayStyle = DevExpress.XtraEditors.FilterCriteriaDisplayStyle.Visual;

how-to-create-and-register-custom-filter-editor-functions/VB/DXApplication5/Main.vb#L19

vb
AddHandler gridView1.QueryCustomFunctions, AddressOf OnQueryCustomFunctions
AddHandler gridView1.FilterEditorCreated, AddressOf OnFilterEditorCreated
gridView1.OptionsView.FilterCriteriaDisplayStyle = DevExpress.XtraEditors.FilterCriteriaDisplayStyle.Visual

See Also

Filter and Search

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace