Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collections with events - is there a better choice than BindingList(of T)?

I needed a generic collection or list that can fire an event when an item is added or removed.

I discovered that BindingList(of T) has events for this and wired up a quick proof of concept that worked fine.

Of course, this doesn't feel like the most educated choice; BindingList is overkill for what I'm doing. Are there any simpler collection/list objects that do this?

I could roll my own of course.

Bonus Points: While we're at it, are you aware of any really comprehensive resources that go over all the .Net collection types in detail?

like image 937
Brian MacKay Avatar asked Dec 12 '25 22:12

Brian MacKay


1 Answers

ObservableCollection(of T) implements INotifyCollectionChanged. It will notify you when items are added or removed. That isn't the same interface as IRaiseItemChangedEvents which is implemented by BindingList(of T). It should work for you though.

like image 75
Mike Two Avatar answered Dec 15 '25 13:12

Mike Two