FlexGrid for WinForms
Customizing filter behavior
Show AllShow All
Hide AllHide All

When filters are applied, the grid hides rows by setting their Visible property to False. But the grid also fires BeforeFilter and AfterFilter events that allow you to customize the filtering behavior. For example, assume that instead of showing and hiding rows you wanted to apply different styles to indicate whether the the rows pass the filter or not. This can be accomplished easily using this code:

To write code in C#

The code creates a custom style that will be used to show rows that did not pass the filter (instead of making them invisible). Next, the code attaches handlers for the BeforeFilter and AfterFilter events. The event handlers are listed below:

To write code in C#

The BeforeFilter event handler calls the new BeginUpdate method to prevent the grid from repainting itself until we are done applying the custom style to the rows that are filtered out. The BeginUpdate and EndUpdate methods replace the Redraw property which has been deprecated.

The AfterFilter event handler starts by retrieving the style we created to show the rows that have been filtered out. It then scans the rows on the grid and applies the new style to all rows that have the Visible property set to False. These are the rows that were hidden by the filter. Once this is done, the code calls EndUpdate to restore grid updating.

See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback