FlexGrid for WinForms
Applying filters programmatically
Show AllShow All
Hide AllHide All

Filters are applied when the user edits them, and also when they are applied to a column. They are not automatically applied when the data changes. To apply the filters to the data currently loaded on the grid, call the grid's ApplyFilters method.

For example, the code below enables an ApplyFilter button when the user edits the data on the grid. Clicking the ApplyFilter button applies the filter and disables the button until the next change.

To write code in C#

The code above binds the grid to a data source, enables filtering by setting the AllowFiltering property to True, and connects an event handler to the AfterEdit event. The event handler implementation follows:

To write code in C#

This code scans all columns to determine whether a filter is defined for any column. If an active filter is detected, the code enables the button that applies the filter to the current data. When the button is clicked, the following event handler executes:

To write code in C#

The code simply applies all the active filters and disables the button until the next change.

If instead of requiring a button click you simply wanted to apply the filter after every edit, you could call the ApplyFilter directly from the AfterEdit event handler, as shown below:

To write code in C#

See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback