Back to Devexpress

ColumnView.CustomFilterDialog Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-53c5a929.md

latest6.2 KB
Original Source

ColumnView.CustomFilterDialog Event

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

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 CustomFilterDialogEventHandler CustomFilterDialog
vb
<DXCategory("Behavior")>
Public Event CustomFilterDialog As CustomFilterDialogEventHandler

Event Data

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

PropertyDescription
ColumnGets the column to be filtered using custom filter criteria.
FilterInfoGets or sets an object specifying custom filter criteria.
HandledGets or sets a value specifying whether the custom filter dialog should be invoked.
ResetEditorEventHandlersGets or sets whether event handlers of the dialog’s editors are reset (i.e., not copied from a column’s in-place editor).
UseAsteriskAsWildcardGets 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.

csharp
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;
      }
}
vb
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Columns

Private Sub GridView1_CustomFilterDialog(ByVal sender As System.Object, _
  ByVal e As CustomFilterDialogEventArgs) Handles GridView1.CustomFilterDialog
      If e.Column.FieldName = "UnitPrice" Then
         e.FilterInfo = New ColumnFilterInfo( _
           ColumnFilterType.Custom, Nothing, "[UnitPrice] < 10 Or [UnitPrice] > 30", _
           "[Unit Price] < '10' Or [Unit Price] > '30'")
         e.Handled = True
      End If
End Sub

See Also

ShowFilterPopupListBox

Filter and Search

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace