I've got a grid displaying schedule information. Each row contains (amongst others) an arrival and a departure column. When the user updates one of these, all following times should be updated automatically by the same interval. This works, except the grid doesn't update the values in the following rows until you click on a row or move the mouse over the changed field, which is a bit confusing for the users.
The grid is bound to a list of POCO objects. In the setter for the Arrival/Departure properties a delegate is called to a function which walks the list and updates the times. The update is done via a method that directly updates the backing variable (to avoid re-cascading the changed) and raises a PropertyChanged event. The grid is an out of the box ultragrid from 10.3.
I've achieved a (rather unsatisfactory) workaround by call DataBind in the grids AfterCellUpdate event handler, but I'm hoping there's a less heavy handed solution.
Kev
peelports said:This works, except the grid doesn't update the values in the following rows until you click on a row or move the mouse over the changed field
Thanks, that did the trick - shouldn't the notify property change have been enough on its own though, or have I missed something?
One last question: I've given them a spin button on the time cells - in a perfect world I'd like to see the other rows updating as I change the value with the spin control? Is this possible at all?
Hi Kev,
No, PropertyChanged won't do anything. The way it works with DataBinding is that the grid hooks into notificatoins provided by the list, not the individual object inside the list.
When you say you are using a "list of POCO objects", what exactly do you mean by "list"? Do you mean a List or IList or a List<T>? Or some other type?
List is not a great choice for a data source, because it's not really designed for data binding. You would be better off using an IBindingList, or BindingList<T> which are explicitly designed for binding. BindingList<T> will raise the correct notificatoins to the grid as long as it is able to detect changes in the objects on the list. To make that work, your objects need to implement INotiffyPropertyChanged.