Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
285
Cell Values Not Updating Until Hover
posted

Hi

I have an ultragrid that is bound via 2 BindingSources to a class derived from System.Collections.ObjectModel.Collection(Of T) where T is a custom class. Both these classes implement INotifyPropertyChanged.

The grid is used to display a series of numeric values and the form has a button that performs a recalculation of these values on request.

The problem I am having is that the grid doesn't update the displayed values properly when the button is clicked.  The active row updates fine, but the other rows only update when I hover over one of the cells in the row (with each row updating one at a time, hovering over 1 row doesn't cause all rows to be updated).

Can anyone guess what I have done wrong?

  • 469350
    Verified Answer
    Offline posted

    Hi,

    If the grid is not updating the display, then it must not be getting a notification that the data has changed.

    INotifyPropertyChanged is not handled by the grid as far as I know. The grid only deals with the DataSource, not the items inside it. So the BindingSource needs to send a ListChanged notification to the grid when something is changed.

    So I believe the way it should work is that the INotifyPropertyChanged notifies the list (in this case, the Collection(Of T) that a change was made, and the list then calls IList.ListChanged. Does your collection do that?

    As far as I know, a Collection implements IList, but not IBindingList. So you may want to consider using a BindingList(Of T) instead of a Collection. The BindingList is more robust for data binding and supports adding rows and other functionality that IList does not. It might even handle the INotifyPropertyChanged for you - although I'm not sure about that.