Presenting FilterList

Earlier today i decided to add ‘Filtering’ to my SortableBindingList. This resulted in writing a FilterList class. This class can be easily used as following:

void textBoxFilter_KeyUp(object sender, KeyEventArgs e)
{
 var filterChars = this.textBoxFilter.Text.ToLower();
 this.Filter(filterChars);
}

void Filter(string filterChars)
{
 var persons = (FilterList<person>)this.dataGridView1.DataSource;
 persons.Filter(p => p.Firstname.ToLower().Contains(filterChars));
}

I even created a screencast to demonstrate it:

[mediaplayer src='http://www.timvw.be/screencasts/filterlist.wmv' width=512 height=344]

  1. Brilliant – many thanks. I cant believe that the Generic List and DataGridViews can cause so much pain. Both your FilterList and the SortableBindingList are brilliant! Do exactly what I’m after. Basically two lists A & B, and I’m filtering both lists, and moving items from one list to another – and modifying items in the list. Awesome. No more troublesome DataGridView not refreshing because I was using the BindingList with Generic Lists… great!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>