tags:

views:

808

answers:

2
+1  Q: 

C# BindingList

Hi, 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

Thank you.

A: 

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...

Hemant
+5  A: 

Your User type need to implement INotifyPropertyChanged.

leppie
Beautiful! This did the job. Thank you so much!
Carlo