Need Both Default Filter & Custom Filter in TrueDBGrid

Posted by: megharpatil13 on 22 December 2022, 2:59 pm EST

    • Post Options:
    • Link

    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%”;

    https://www.grapecity.com/componentone/docs/win/online-truedbgrid/C1.Win.C1TrueDBGrid.4.5.2~C1.Win.C1TrueDBGrid.C1DataColumn~FilterOperator.html

    Regards,

    Prabhat Sharma.

    file-e3b9be57-2211-4267-ab18-b71e8b64bbbe.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels