Skip to main content Skip to footer

Show Tri-State Checkbox for Boolean Fields in C1DataFilter


By default, C1DataFilter applies C1.Win.DataFilter.BoolFilter for a Boolean column in a data source. With the BoolFilter applied, the records will either be filtered for the true values or for the false values. Nthat is, no filter state will display both values simultaneously. However, there may be times where the application might need a third state that shows true, false, or both values.  

This article explains how to show a tri-state checkbox as a filter in C1DataFilter, where the checked state shows true values, the un-checked state shows false values, and the gray state shows both values. 

Steps to Complete:

  1. To show a tri-state checkbox as a filter, create a custom filter ‘CheckBoxFilter’ by inheriting the C1.Win.DataFilter.CustomFilter class, set its control to a CheckBox with the ThreeState property set to “true.” 

  2. Next, define the filter’s expression by overriding the filter’s GetExpression method. The following is the complete code for the custom filter class:  

  3. To use the custom filter created above, add it to the C1DataFilter’s Filters collection, like so:

Below, you can compare the behavior before and after using a CustomFilter:



Ruchir Agarwal