Posted 22 December 2022, 2:59 pm EST
The Default Filter is working fine . For example if my data is
John
Micheal
Mischell
the default filter will work fine if I type “Mi” in filter box.
But When I need “che” to be filtered what should be done?
Forums Home / ComponentOne / WinForms Edition
Posted by: megharpatil13 on 22 December 2022, 2:59 pm EST
Posted 22 December 2022, 2:59 pm EST
The Default Filter is working fine . For example if my data is
John
Micheal
Mischell
the default filter will work fine if I type “Mi” in filter box.
But When I need “che” to be filtered what should be done?
Posted 23 December 2022, 5:47 am EST
Hello Megha,
To achieve this type of filtering functionality you need to set the AllowFilter property to False and handle the FilterChange event as per your requirement.
private void c1TrueDBGrid1_FilterChange(object sender, System.EventArgs e)
{
// build our filter expression
StringBuilder sb = new StringBuilder();
foreach(C1.Win.C1TrueDBGrid.C1DataColumn dc in this.c1TrueDBGrid1.Columns)
{
if( dc.FilterText.Length > 0 )
{
if( sb.Length > 0 ) sb.Append(" AND ");
// Contains Filter
sb.Append(dc.DataField + " like " + “‘" + dc.FilterText + "’”);
}
}
// filter the data
this.dataSet11.Tables[0].DefaultView.RowFilter = sb.ToString();
}
Please find the attached sample implementing the same.
If you do not want to handle the FilterChange event then you can use the FilterOperator property of the specified column as given in the code snippet below:
c1TrueDBGrid1.Columns[columnIndex].FilterOperator = “%LIKE%”;
Regards,
Prabhat Sharma.
file-e3b9be57-2211-4267-ab18-b71e8b64bbbe.zip