Question

I'm trying to create some search mechanic on a ObjectListView control. According to the documentation this can be done by adding a TextMatchFilter to the control:

this.olv1.ModelFilter = TextMatchFilter.Contains(this.olv1, "search");

After executing this line, the olv1 will only show rows where the text “search” occurs in at least one cell of that row.

This is what I have done so far:

private void textBoxSearch_TextChanged(object sender, EventArgs e)
{
    projectObjectListView.ModelFilter = TextMatchFilter.Contains(projectObjectListView, toolStripTextBox_search.Text);
}

Whenever I type in my textbox the TextMatchFilter is set to my ObjectListView. I have set all columns to be searchable but when I start typing, nothing happens. The event fires as it should and the Filter get set to the OLV Modelfilter, but no reaction. Anyone have experienced the same problem?

Was it helpful?

Solution

You have to set the UseFiltering property on the ObjectListView to true, otherwise the OLV will ignore any assigned ModelFilter.

To enable filtering on a list, you must set UseFiltering to true. To ensure backward compatibility, it is false by default.

Source

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top