Can anyone suggest a good implementation of a generic collection class that implements the IBindingListView
& IBindingList
interfaces and provides Filtering and Searching capabilities?
I see my current options as:
BindingList<T>
, and implementing the IBindingListView
interfacesIBindingListView
and IBindingList
.Obviously, the first option is my preferred choice.
I used and built upon an implementation I found on and old MSDN forum post from a few years ago, but recently I searched around again and found a sourceforge project called BindingListView. It looks pretty nice, I just haven't pulled it in to replace my hacked version yet.
nuget package: Equin.ApplicationFramework.BindingListView
Example code:
var lst = new List<DemoClass> { new DemoClass { Prop1 = "a", Prop2 = "b", Prop3 = "c" }, new DemoClass { Prop1 = "a", Prop2 = "e", Prop3 = "f" }, new DemoClass { Prop1 = "b", Prop2 = "h", Prop3 = "i" }, new DemoClass { Prop1 = "b", Prop2 = "k", Prop3 = "l" } }; dataGridView1.DataSource = new BindingListView<DemoClass>(lst); // you can now sort by clicking the column headings // // to filter the view... var view = (BindingListView<DemoClass>)dataGridView1.DataSource; view.ApplyFilter(dc => dc.Prop1 == "a");
Here is the help for your method 2 and 3 Behind the Scenes: Implementing Filtering for Windows Forms Data Binding
http://www.microsoft.com/downloads/details.aspx?FamilyID=4af0c96d-61d5-4645-8961-b423318541b4&displaylang=en
A couple of solutions I can think of:
The SubSonic Project has a pretty nice implementation of BindlingList<T>
which is open source. Although this might require using the entire SubSonic binary to use their implementation.
I enjoy using the classes from the Power Collections project. It is fairly simple to inherit from one of the base collections there and implement IBindingListView
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With