Skip to main content Skip to footer

Customizing FilterEditorDropDown in C1FlexGrid for WinForms

C1FlexGrid has been a very popular grid control due to its flexibility for customization. We can modify the appearances, styles and lots of other UI features in C1FlexGrid. However, there are certain things that are still not accessible for modifications. One we are going to talk about is the FilterEditorDropDown. Within FilterEditorDropDown we have a lot of Child Controls like Buttons, Dropdowns and List Items. These buttons for ‘Clear,' ‘Apply’ and ‘Cancel’ have some predefined text. At times, we may like to change this text to show our own customized text. In this blog, we provide a small hack to access these controls and make the required changes. The basis of this hack is that the FilterEditorDropDown is a Form which acts as a container to all the controls so our aim is to get a hold of this Form. Once we can get this Form we can loop through its Child Controls and modify the settings. So how do we get this Form object? This FilterEditorDropDown form opens as a part of OpenForms collections of the Application. When we click on the FilterIcon, FilterEditorDropDown is added to the OpenForms collections. We first have to determine whether the user has clicked on ‘FilterIcon.' Using the ‘HitTest()’ method we can find out if the user has clicked on ‘FilterIcon.'


void c1FlexGrid1_MouseDown(object sender, MouseEventArgs e)  
{  
   if (c1FlexGrid1.HitTest().Type == C1.Win.C1FlexGrid.HitTestTypeEnum.FilterIcon)  
   {  
       ResizeFilterWindow();  
   }  
}  

HitTest() method has made it very simple to know which part of C1Flexgrid the user has clicked. Once we have determined the click action on the FilterIcon we make a call to a separate module (‘ResizeFilterWindow’) where we define all the codes to get for the form and access the Child Controls.


private void ResizeFilterWindow()  
{  
      foreach (Form f in Application.OpenForms)  
      {  
          if (f.Name == "FilterEditorForm" && f.GetType().ToString() == "C1.Win.C1FlexGrid.FilterEditorForm")  
          {  
                    ((System.Windows.Forms.ToolStrip)(f.Controls[0])).Items[1].Text = "Remove Filter";  
                    f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;  
                    f.Text = "Filter Window";  
                    f.MaximizeBox = false;  
                    f.MinimizeBox = false;  
          }  
      }  
}  

Once you know how to access the Child Controls you can retrieve the desired control and play with it to modify the desired settings. You can download the sample from the link below.

Download Sample

OK, here’s a disclaimer :). This is just a workaround and may have some limitations. You may or may not be able to alter all the settings.

MESCIUS inc.

comments powered by Disqus