Skip to main content Skip to footer

HowTo: Customize FilterEditor of C1FlexGrid

ComponentOne FlexGrid allows end users to filter columns based on their values by using C1FlexGridFilterService. This service needs FlexGridFilter dll to be present in the project. This blog discusses about customizing the FilterEditor. This FilterEditor has some conditions, values and buttons to apply, cancel or clear the filter. The default filter pop up looks like the image below:

DefaultFilterEditor

As shown in the image above, we may sometime need to hide or remove the buttons/conditions which are not needed for the default FilterEditor. This can be easily achieved using VisualTreeHelper class which is available with C1.Silverlight dll. Using GetChildrenOfType() method of VisualTreeHelper class, we can get elements present on the FilterEditor like Buttons, ComboBoxes, RadioButtons, TextBlocks etc. Here, we are removing the "Clear" button from filter Editor.


   var f = C1FlexGridFilterService.GetFlexGridFilter(c1FlexGrid1);  
   f.EditorOpened += new EventHandler(f_EditorOpened);  
   void f_EditorOpened(object sender, EventArgs e)  
   {  
      var filter = sender as C1FlexGridFilter;  
      var editor = filter.Editor;  
      IList list = new List();  
      VTreeHelper.GetChildrenOfType(editor, typeof(Button), ref list);  
      // Hide the Clear Button  
      (list[1] as Button).Visibility = System.Windows.Visibility.Collapsed;  
   }  

CustomizedFilterEditor

Similarly, we can show or hide other elements of FilterEditor using the same approach. Download C# Sample Download VB.Net Sample

MESCIUS inc.

comments powered by Disqus