Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Expand]Data Editing
   [Collapse]Filtering and Locating Rows
    [Collapse]Filtering
     [Expand]Filter Dropdowns
     [Collapse]Tutorials
       Tutorial: Column Filter Dropdowns
       Tutorial: Data Filtering Basics and Filter Panel Settings
       Tutorial: Excel-Style Custom Filter Dialog
       Tutorial: Filter Editor
       Tutorial: Filter Row
       Tutorial: Filtering and Locating Rows API
      Filtering Overview
      Filter Settings
      MRU Filters
      Automatic Filtering Row
      Filter Editor
      Custom Filter Dialog
      Filtering in Code
     Locating Rows in Code
     Incremental Search
     Searching via Find Panel
     Tutorial: Incremental Search
     Tutorial: Search/Find Panel
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Tutorial: Excel-Style Custom Filter Dialog

This walkthrough is a transcript of the Excel-Style Filter Dialog video available on the DevExpress YouTube Channel.

In this tutorial, you will learn how to use the Excel-Style Filter Dialog available to end-users by default, how to switch to a version that allows you to compare values from one field to values in another, how to manually invoke and customize these dialogs in code.

Expanded Standard Custom Filter Dialog

To invoke the Excel-Style Filter Dialog for a column, click this column's filter button and select (Custom) in the dropdown.

The dialog allows end-users to create criteria that consist of one or two conditions combined by AND or OR logical operators. Change the comparison operator of the first condition to Is greater than. In the dialog to the right, enter the value 10. Leave the AND logical operator selected. For the second condition, choose Is less than and enter the value 30. Click OK to apply the created filter condition.

As a result, the grid displays records whose unit price is between 10 and 30 dollars.

Expanded Advanced Custom Filter Dialog

Close the application. Select the View, expand its ColumnView.OptionsFilter property and enable the ColumnViewOptionsFilter.UseNewCustomFilterDialog option.

Run the application to see the change. Now when you select (Custom) in a column's filter dropdown, a different version of the Custom Filter Dialog is used. This dialog additionally provides the capability to compare current column values to values in another column. Activate this mode for the first condition by selecting the Field check box, and choose the Discount Price column in the dropdown list. Then, change the comparison operator to Does not equal. For the second condition, choose Is less than and enter the value 20. Click OK to show only those records that have a discount assigned while the unit price is less than 20.

Expanded Invoking and Customizing Filter Dialogs in Code

The next step is to see how the Custom Filter Dialogs can be invoked and customized in code.

To invoke the Custom Filter Dialog for the Category column in the Click event handler for the Show Custom Filter Editor button, call the View's ColumnView.ShowCustomFilterDialog method and pass the Category column as a parameter.

Filter Dialogs can be customized in the View's ColumnView.CustomFilterDialog event, which is raised when an dialog is about to be displayed. Write a handler for this event that will suppress the default dialog for the Unit Price column and then will apply a custom filter condition. The event's CustomFilterDialogEventArgs.Column parameter identifies the column to be filtered. Specify the desired filter condition and text to be displayed within the filter panel, and create a new ColumnFilterInfo object with these settings. Then, assign the new filter item to the event's CustomFilterDialogEventArgs.FilterInfo parameter. Finally, set the CustomFilterDialogEventArgs.Handled parameter to true to prevent the default Filter Dialog from being invoked after event execution.

Run the application and click the Show Custom Filter Editor button. A filter dialog will be displayed for the Category column. In the invoked dialog, specify two conditions to display records from the Beverages and Confections categories. Now invoke the Unit Price column's filter dropdown and select (Custom). This selects records whose unit price is between 10 and 30.

Expanded See Also

How would you rate this topic?​​​​​​​