Slicers are common on e-commerce websites—they help users filter items with all the filtering options are available in one place, and with a variety of controls appropriate to the data: checklist, range-bar, radio buttons, etc. In WinForms Edition 2018 v3, we've introduced a beta version of that filter, which can be attached to any data-aware control.

The filter layout often consists of an accordion providing expand/collapse options for filter criteria:

Example of an Amazon Filter

Let's look at some uses for the new WinForms DataFilter control.

Filter multiple controls in a dashboard with the DataFilter

Dashboards are an ideal use case for DataFilters, because all information on the screen can be filtered at one place interactively, giving users the option to derive more meaning out of data. In addition, each visual could be connected to a DataFilter for further drill down.

A product catalogue involves lot of information about products, and a slicer comes in handy:

DataFilter with a card view

Integrate the DataFilter control into a FlexGrid

Slicers can be a useful interactive filtering tool when working with data controls like a Grid or TreeView. When users can filter on multiple columns, it's easier to set them all in one place:

DataFilter integration with a FlexGrid

Architecture of the WinForms DataFilter

DataFilter uses C1CollectionView for filtering. C1CollectionView is similar to the .NET CollectionView, which supports filtering, grouping, sorting over a collection.

How CollectionView works

Internally, when the Data Filter creates a filter expression based on user choices, the expression is passed to C1CollectionView. C1CollectionView creates a view of the data source and applies the filter based on this expression.

User interface of the DataFilter

The basic layout used by the data filter control is an accordion. Each filter item is stacked one after the other, where each can be collapsed and expanded.

WinForms DataFilter interface

Auto-selection of filter types in DataFilter

The control generates different filter controls for different types of data:

  1. For a boolean data field, the DataFilter control generates a BoolFilter, represented by a checkbox.
  2. For a numeric data field, the control generates a RangeFilter, which provides range editors and a range slider to filter values in the specified range.
  3. For textual/string data field, the control generates a ChecklistFilter, which allows users to select and filter items from a checklist.
  4. For a DateTime data field, the control generates a DateRangeFilter, which provides range editors and a range slider to filter values in the specified date range.

Asynchronous filtering

When working with large data, it's good practice to apply the filtering asynchronously so as to not block the UI. DataFilter control has a built-in method called ApplyFilterAsync to apply asynchronously.

Save and load filters

The DataFilter control supports serialization through SaveFilterExpression and LoadFilterExpression methods of the C1DataFilter class. The SaveFilterExpression method saves the current filter expressions from C1.Win.DataFilter.C1DataFilter.Filters collection to an XML file. The LoadFilterExpression method loads the saved filter expressions from an XML file.

Styling the WinForms DataFilter control

The C1DataFilter class provides a Styles property that can be used to customize the appearance of the DataFilter control and its elements. Here you can see how you can edit buttons, filters, checkboxes, editors, header, filter captions, and scrollbars:

WinForms DataFilter editable styles

Applying themes to the DataFilter

All themes included in the WinForms studio are supported by DataFilter, including the recently-added Material and Office 2016 themes. Use the C1ThemeController to apply the theme application-wide:

WinForms DataFilter theme options

DataFilter is quite useful in number of applications. Please share your suggestions and feedback to help us improve and add features for the launch in 2019 v1!

Read more about DataFilter

Try the WinForms DataFilter control

Get the latest version of ComponentOne Studio Enterprise

Download Now!