$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
GridView Windows Forms Control
Filtering data in GridView in C# Windows Forms applications
Home > WinForms UI Controls > User Manual > Data Grid Filter like Excel in C#

GridView Excel-like Filtering in Windows Forms

The Kettic GridView provides the support of Excel-Like filtering. This gird data filtering feature allows the end users of your application perform the filtering just like in Excel. This filtering functionality includes the filtering dialog and the list of distinct column values for selection by the end users. Moreover, the Excel-Like filtering feature provides the default filters of menu item as well as custom filter form for the users.

How to Enable Excel-like Filtering in C#

The Kettic GridView .NET WinForms control contains the EnableFilter and DisplayHeaderCellButtons property for the users to enable the excel-like filtering functionality. The C# code below shows how to achieve this.

this.ketticGridView1.EnableFilter = true;
this.ketticGridView1.MasterTemplate.DisplayHeaderCellButtons = true;
this.ketticGridView1.MasterTemplate.DisplayFilteringRow = false;
While using the DisplayHeaderCellButtons property, it is able to specify it on grid templates level, including the scenarios with mixed filter functionality on the various hierarchy levels. So, when the value of the DisplayFilterRow property is still true, the excel-like data filtering will be synchronized with the previous filter row functionality.
If we do not think of specifying the Excel-like filtering feature to a specific column, we can disable the ApplyFilter property to False for the grid column. This is achieved by using the simple C# code below.

this.ketticGridView1.Columns["ProductName"].ApplyFilter = false;

How to Customize Excel-like Filtering Popup

The Kettic GridView allows the users of the control create custom Excel-like filtering popup. This is achieved through the FilterPopupRequired event which will be fired as long as the filter popup appearing. By this event, we can easily access to current filter popup via FilterPopup argument and create Excel-like filtering popup.
The following is a sample that demonstrates how to create custom Calendar filter popup. The popup will help the users easily select the specific date, or period. The C# code below will clear the default custom items, and add custom item to this popup.

void ketticGridView1_FilterPopupRequired(object sender, Kettic.WinForms.UI.FilterPopupRequiredEventArgs e)
{
if (e.FilterPopup is KetticDateFilterPopup)
{
KetticDateFilterPopup popup = (KetticDateFilterPopup)e.FilterPopup;
popup.ClearCustomMenuItems();

popup.AddCustomMenuItem("Tomorrow", new DateFilterDescriptor(e.Column.Name, FilterOperator.EqualTo, DateTime.Tomorrow));
}
}

Create Simple List Filter Popup

The simple list filter popup is able to perform the data filtering easily and quickly according to a simple list and a simple. To customize it, we need to use the FilterPopupRequired event and the C# code below shows how to achieve this.

void ketticGridView1_FilterPopupRequired1(object sender, Kettic.WinForms.UI.FilterPopupRequiredEventArgs e)
{
if (e.Column.Name == "ProductName")
{
e.FilterPopup = new KetticSimpleListFilterPopup(e.Column);
}
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls