Hi there,
The Grid, backed by an IBindingList Datasource doesn't seem to resort itself when the underlying collection changes. Is there anything I need to "turn on" to enable re-sorting after underlying collection changes?
Mark
Mark,
I don't think that the grid is designed to automatically resort each time the colletion changes, since there are many applications that update the data several times a second, and this could be very jarring to the user. What you can do is call the RefreshSort method:
this.ultraGrid1.DisplayLayout.Bands[0].SortedColumns.RefreshSort(true);
-Matt
I'll rephrase my question. It looks like the grid *does* re-sort after data binding once you have clicked on a column header, but it doesn't re-sort if you specify a default column sort at design time.
Regarding calling RefreshSort. This is a small problem because, when using MVVM I would need to somehow tell me view that the underlying model has changed in correlation to updating the IBindingList (I guess the view *could* listen in on the changed events.
Does the grid implement an "OnDataBindingComplete" event so you can tell that data binding recently occurred?
No, there isn't really a DataBindingComplete event, but if you have a column sorted at design-time, when the grid first accesses the data source, it should display the rows in the sorted order. The exception to this would be if the data source changes in the middle of the time during which the grid is building the collection of rows. The best solution here is to listen to changes on the data source; the IBindingList interface provides a ListChanged notification that you can hook and tell the grid to update at that point.