Search code examples
c#objectlistview

Objectlistview TextMatchFilter Filter and not Highlight


i try to use TextMatchFilter for my ObjectListView. I do not know why, but instead of Filterung (what i want), the function only highlights the words. So i want the whole ObjectListView to show only the Rows where the Filter is true.

This is my Code:

 this.fastoLV_Clean.ModelFilter = TextMatchFilter.Contains(this.fastoLV_Clean, "Test");
 fastoLV_Clean.Refresh();

Does anyone know, what i have to do to really Show only the rows and not to only highlight the ones in which it was found?

Regards and thank you,


Solution

  • You need to set the UseFiltering property of your ObjectListView to be True

    If you don't set this, then it will just highlight your text. When set, then it will filter and only show the relevant rows.

    BTW: You don't need to call fastoLV_Clean.Refresh()

    A Refresh is normally only needed in some cases, such as when you change the columns programmatically. It is not needed for simple things such as this when you model data is updated. (I noticed this also in your other post, but forgot to mention it!)