ColumnView.CustomFilterDisplayText Event

Allows you to customize the display text representing the current filter within the filter panel.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

[DXCategory("Behavior")]
public event ConvertEditValueEventHandler CustomFilterDisplayText
<DXCategory("Behavior")>
Public Event CustomFilterDisplayText As ConvertEditValueEventHandler

Event Data

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

Property Description
Handled Gets or sets a value specifying whether default edit value conversion/formatting is required.
Value Gets or sets either the edit or the display value of an editor.

Remarks

The CustomFilterDisplayText event allows you to customize the display text of a specific filter (generally, the text displayed within the Filter Panel). When the event fires, its Value parameter specifies the current filter criteria which is represented by a CriteriaOperator object. Depending on the current criteria you can provide specific filter display text. To specify the filter display text, assign the required string (or any object whose ToString() method returns the required string) to the Value parameter and set the Handled parameter to true.

It's also possible to provide custom filter display text for filters when the filters are created using ColumnFilterInfo constructors. To do this, specify the filter display text using the constructor's 'displayText' parameter.

Example

In the following example the ColumnView.CustomFilterDisplayText event is handled to display the "No Filter" string in the filter panel when a View's data is not filtered.

If a View's data is not filtered the event's Value parameter is set to null. In this instance, the custom display text that needs to be displayed in the filter panel is assigned to this parameter. If the View is filtered, the Value parameter specifies a valid CriteriaOperator object, which represents the current filter criteria. In this instance, the example illustrates the textual representation of the current filter is assigned to the Value parameter. Alternatively, you can check the current CriteriaOperator object, to provide custom display text depending upon the current filter.

The result for a sample grid control is displayed below:

ColumnView.CustomFilterDisplayText_ex

private void gridView1_CustomFilterDisplayText(object sender, 
    DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e) {
    if (e.Value == null) {
        e.Value = "No Filter";                
    }
    else {
        e.Value = e.Value.ToString();
    }
    e.Handled = true;            
}
See Also