Skip to main content

ColumnView.CustomFilterDialog Event

Enables the Custom Filter Dialog to be replaced with custom filtering facilities.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v23.2.dll

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

Declaration

[DXCategory("Behavior")]
public event CustomFilterDialogEventHandler CustomFilterDialog

Event Data

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

Property Description
Column Gets the column to be filtered using custom filter criteria.
FilterInfo Gets or sets an object specifying custom filter criteria.
Handled Gets or sets a value specifying whether the custom filter dialog should be invoked.
ResetEditorEventHandlers Gets or sets whether event handlers of the dialog’s editors are reset (i.e., not copied from a column’s in-place editor).
UseAsteriskAsWildcard Gets or sets whether the asterisk (‘*’) character can be used as a wildcard character.

Remarks

End-users are allowed to apply data filtering using filter dropdowns. Filter dropdowns provide a Custom item that invokes the Custom Filter Dialog. The dialog’s appearance and functionality are dependent upon the ColumnViewOptionsFilter.UseNewCustomFilterDialog property’s value. To provide your own custom filter dialog, handle the CustomFilterDialog event.

The event’s parameters enable the column for which the filter dropdown was activated to be identified. Use the CustomFilterDialogEventArgs.Column parameter for this purpose. To display a custom dialog or perform other actions, set the CustomFilterDialogEventArgs.Handled parameter to true. This will suppress the default filter dialog. When the desired actions have been performed, apply the specified filter using the CustomFilterDialogEventArgs.FilterInfo parameter.

To change the Custom item’s caption or remove it from the filter dropdown, handle the ColumnView.ShowFilterPopupListBox event.

Please refer to the Filter and Search topic for additional information.

Example

The following sample code implements custom filtering and disables the Custom Filter Dialog dialog for the UnitPrice column.

When a (Custom) item is selected in the filter dropdown a custom filter criteria will be created and applied to the View. These criteria select records which contain values less than 10 or greater than 30 in the “UnitPrice” column.

using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Columns;

private void gridView1_CustomFilterDialog(object sender, CustomFilterDialogEventArgs e) {
      if (e.Column.FieldName == "UnitPrice") {
         e.FilterInfo = new ColumnFilterInfo(
           ColumnFilterType.Custom, null, "[UnitPrice] < 10 Or [UnitPrice] > 30", 
           "[Unit Price] < '10' Or [Unit Price] > '30'");
         e.Handled = true;
      }
}
See Also