The ListChanged event for an IBindingList fires a type ListChangedType.ItemDeleted when items are deleted, perhaps by a user deleting a row in a datagrid control bound to the list. The problem is that the NewIndex into the list is invalid in this event, it’s been deleted, and the item that was deleted is not available. There should be an ItemDeleting event, but I doubt they will ever fix this.
The ListChanged event for an IBindingList fires a type ListChangedType.ItemDeleted when items are deleted,
Share
Yeah it’s pretty annoying, but there is an easy workaround. I create a
BindingListBase<T>class that I use for all of my lists instead of using a normalBindingList<T>. Because my class inherits from theBindingList<T>, I have access to all of it’s protected members, including theRemovedItemmethod.This enables me to pick up when an item is removed. You could do what I do and have a mRemovedItems list that I always add items to, or raise your own ‘ItemRemoved’ event.
See my code example below: