"ApplySearch" and invisible columns

Originally Posted 13 January 2017, 4:15 am EST

  • Originally Posted 13 January 2017, 4:15 am EST

    Hi C1,

    the new "ApplySearch" method is great. But one question/problem: it seems that it also searchs invisible columns and thus shows a row even if all visible cols don't contain the search string.

    Would it be possible to change this - even with an additional parameter to "ApplySearch"?

    Best regards

    Wolfgang
  • Reply

    Hello Wolfgang,

    I could replicate this at my end too and have asked the concerned team to add an overload to this method that would consider searching only the visible columns.
    However until we have this feature added, as a workaround you could try adding the following lines of code in your application,after using ApplySearch() method:
      
    for (int r = 1; r < c1FlexGrid1.Rows.Count; r++)
    {
    flag = false;
    if (c1FlexGrid1.Rows[r].Visible)
    {
    for (int c = 1; c < c1FlexGrid1.Cols.Count; c++)
    {
    if (!c1FlexGrid1.Cols[c].Visible)
    {
    int index = c1FlexGrid1.GetData(r, c).ToString().IndexOf(searchString, StringComparison.CurrentCultureIgnoreCase);
    if(index!=-1)
    {
    flag = true;
    break;
    }
    }
    }
    if (flag)
    {
    c1FlexGrid1.Rows[r].Visible = false;
    }
    }
    }


    This should meet your requirement.

    Attached is sample application for reference.

    Regards
    Ruchir Agarwal
    2017/01/prj_ApplySearchInvisbleColumns.zip
  • Marked as Answer

    Reply

    Hi Ruchir,

    thanks for the workaround. But in the moment, it is not required - it was just something that I noticed. Probably our customers won't see this ;-)

    Best regards

    Wolfgang
  • Reply

    Hi Wolfgang,

    We are pleased to inform you that an overload to the "ApplySearch(string search, bool highlight, bool filter, bool onlyVisibleColumns)" method has been added in the latest release of C1_WinForms. You may download the same from the following links:
    http://prerelease.componentone.com/dotnet40/c1winforms/2017-t1/C1WinForms.4_4.0.20171.248.zip
    http://prerelease.componentone.com/dotnet20/c1winforms/2017-t1/C1WinForms.2_2.0.20171.248.zip

    Best Regards
    Ruchir Agarwal
  • Reply

    Thanks, I had noticed this myself ;-)

    Wolfgang
Need extra support?

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

Learn More

Forum Channels