Carlo
Carlo

Reputation: 25969

BindingList.ListChanged Event not Raised when Property Changes

I have a BindingList of type User, the User object has several properties (UserName, Password, etc). So I tied an event handler to the BindingList.ListChanged event, and it works fine when adding or deleting a user, BUT, if a user property changes, it does not raise the event, is there any way to achieve this?

bindingListUsers.Add(someUser); // This raises ListChangedEvent

bindingListUsers.Delete(someUser); // This raises ListChangedEvent

bindingListUsers[0].UserName = "Another user name"; // This does NOT raise the event

Upvotes: 6

Views: 5232

Answers (2)

leppie
leppie

Reputation: 117360

Your User type need to implement INotifyPropertyChanged.

Upvotes: 10

Hemant
Hemant

Reputation: 19846

The only way I can think of is define an event in User class which is fired when a property value is changed (you have to write code manually for that). Then create a wrapper class of binding list. Handle both list events and user class events in that class.

I can elaborate more if you like the idea...

Upvotes: 0

Related Questions