Back to Devexpress

VGridControl.CustomFilterDisplayText Event

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrol-4f790839.md

latest5.1 KB
Original Source

VGridControl.CustomFilterDisplayText Event

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

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

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

Declaration

csharp
public event ConvertEditValueEventHandler CustomFilterDisplayText
vb
Public Event CustomFilterDisplayText As ConvertEditValueEventHandler

Event Data

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

PropertyDescription
HandledGets or sets a value specifying whether default edit value conversion/formatting is required.
ValueGets 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 a 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.

Example

In the following example, the VGridControl.CustomFilterDisplayText event is handled to display “No Filter” in the filter panel when the control’s data is not filtered.

If the control’s data is not filtered, the ConvertEditValueEventArgs.Value event parameter is set to null ( Nothing in VB). In this instance, the custom display text that needs to be displayed in the filter panel is assigned to this parameter.

If the control’s data is filtered, the ConvertEditValueEventArgs.Value event parameter specifies a valid CriteriaOperator object, which represents the current data filter. In this instance, the example illustrating the textual representation of the current filter is assigned to the ConvertEditValueEventArgs.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 vertical grid control is displayed below.

Note

The VGridOptionsView.ShowFilterPanelMode setting of the control’s VGridControlBase.OptionsView should be set to ShowAlways to enable the filter panel to be displayed even if no data filter is currently applied.

csharp
private void vGridControl1_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;
}
vb
Private Sub VGridControl1_CustomFilterDisplayText(sender As Object, e As DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs) Handles VGridControl1.CustomFilterDisplayText
    If e.Value Is Nothing Then
        e.Value = "No Filter"
    Else
        e.Value = e.Value.ToString()
    End If
    e.Handled = True
End Sub

See Also

CustomDrawFilterPanel

VGridControl Class

VGridControl Members

DevExpress.XtraVerticalGrid Namespace