August 19, 2005

Active BindingListView

Well it took me two days of playing with code and about 4 attempts, but I finally have what I wanted: An active filtering, active sorting, searchable BindingListView<T>. It serves as a data bindable view for a BindingList<T>, in the same way that a DataView provides a bindable view of a DataTable.

The BindingList<T> does provide a nice easy way to quickly databind a list of business objects to a UI, but it is lacking in certain areas. While you can just inherit from BindingList<T> to add simple sorting, etc, this then involves altering the internal list of data. While this is fine in simple cases it is not practical when you need multiple views of the same data and want to sort by multiple columns for example.

The really neat stuff is where adding/editing an item still maintains the current filter and sort.
It can sort by multiple columns (ascending or descending).
It can filter via implementations of the IItemFilter<T> interface, for example using a simple Predicate<T> delegate. But I may write a expression parser (for that SQL WHERE clause style filter) or even one that can compile C# or VB.NET on the fly to create the item filter logic.

Basically I'm totally chuffed! :D
I am planing to write an article detailling the code soon (once my hands recover from 2 days of coding!), so watch this space…

- 6 comments by 1 or more people Not publicly viewable

[Skip to the latest comment]
  1. KjellSJ

    Nice work, just what I was looking for.

    13 Oct 2005, 10:59

  2. Excellent! I'm glad someone is finding it useful.

    13 Oct 2005, 21:00

  3. Francis Norton

    If you're still thinking of adding an expression parser you might want to have a look at LINQ: – this would make a nice little case study.

    16 Mar 2006, 16:49

  4. Yes I think LINQ is definately the way forward. I'm already playing with it on other projects and loving every minute! Maybe there's a way to pass a LINQ expression as an abstract syntax tree to the BindingListView and then use it to filter items…

    17 Mar 2006, 02:44

  5. Chris

    I must be blind for I cannot see the code anywhere! Would love to see it!

    05 Jun 2007, 23:49


    08 Jun 2007, 15:53

Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

Google Ads

Search this blog

Most recent comments

  • I scratched my eye while i was holding some kind of plastic packaging.. Anyways the corner of the pl… by Ercan on this entry
  • About a year ago my contacts that i was wearing, i guess were fautly, because shortly after they wer… by Jon on this entry
  • I got shower gel in my eye 4 and a half days ago, and becasue i rubbed my eyes a lot, i have scratch… by Chris on this entry
  • This website may help–health/tc/Eye–Injuries–Home–Treatment by S on this entry
  • I somehow got dirt, or debris in my eye. The terrible pain sent me in a tailspin. I was afraid of sa… by Bobbi on this entry


August 2005

Mo Tu We Th Fr Sa Su
Jul |  Today  | Sep
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31            


Blog archive

Not signed in
Sign in

Powered by BlogBuilder