ColumnView.CustomFilterDisplayText Event
Allows you to set a custom Filter Panel text. This techique is aplicable only when the Filter Panel is in “Text” mode (see the FilterCriteriaDisplayStyle property).
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.1.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
Declaration
[DXCategory("Behavior")]
public event ConvertEditValueEventHandler CustomFilterDisplayText
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.
Note
The CustomFilterDisplayText event allows you to modify filters’ captions only when the Filter Panel is in “Text” mode (see the FilterCriteriaDisplayStyle property).
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:
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;
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomFilterDisplayText 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.