I have a BindingList<T> and a grid bound to that collection.
I see when I add and remove items from the list the grid updates with those modifications.
However it does not update when an item in that list changes.
How can I get this to happen?
UPDATE: It seems that this might be a grid painting issue. If I click on the row for the item that has been modified it then refreshes with the new values. How can I resolve this?
UPDATE 2 : Calling Grid.Refresh() shows the updated value as well. This can't be right?
I didn't write the BindingList class, but I would guess that every time you add an item to the list, it checks to see if the item implemented INotifyPropretyChanged and if it does, hooks the PropertyChanged event.
I'm not sure why you are asking. You don't have to do anything to get it to hook the events, if that's what you want to know.
Thanks.
How does the BindingList create an eventhandler to the event raised by the properties in my class?
Hi,
The BindingList will send notifications to the grid that something has changed when it knows about the changes. The BindingList knows, for example, when you add or remove items from the list.
But if you change a property on an item in the list, there's no way for the BindingList to know that this happened - unless the objects in your list implement the INotifyPropertyChanged interface and send notifications when something changes.
When you mouse over the grid or call Refresh, the grid paints the cells and it asks for the values from the DataSource, so that's why that works. But it's not very efficient.