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
3166
Group By column not refreshing on BindingList.SetItem
posted

I am binding the UltraGrid to a typed BindingList. When I am replacing the item in the list using SetItem my Group By column is not refreshed.

Binding.ListChanged event is raised with ItemChanged with OldIndex=-1

I am using SetItem as I don't want to raise two events to Remove and Insert.

internal class MyBindingList : BindingList
{
 public void ReplaceRow(int index, MyRow row)
 {
    SetItem(index, row);
    //RemoveAt(index);
    //Insert(index,row);
 }
}

PS: Using infragistics version 2010.3

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi Bhavesh,

    There isn't really any notification in WinForms for replacing an entire object in the data source with a new object. But even if there was, the grid does not automatically re-sort when the data changes. The reason it does not do this is that if the user is typing into a cell and they change a value, you wouldn't want the row to move to a new position as soon as the user leaves that cell.

    So you basically have 3 options here:

    1) You can do the Remove and Insert. I haven't actually tried this out, but I assume when a new row is inserted, the grid has no choice but to add that row into the correct group. This, in my opinion, would be the least inefficient option.

    2) If you can find the row in the grid, you can call row.RefreshSortPosition. This re-sorts a single row into the correct position, on the assumption that only the one row has changed. This re-sorting of the individual row is pretty efficient, but find the row based on the ListObject (the BindingList row) probably is not very easy or efficient. You can try using GetRowWithListIndex, but this is on the Rows collection, so you would first have to find the GroupByRow that the row currently exists in first, and the only way to do that would be to iterate all of the rows - and if you have multiple levels of grouping, you would have to walk down recursively.

    3) You can call

    this.ultraGrid1.DisplayLayout.Bands[0].SortedColumns.RefreshSort(true);

    This is the most destructive and inefficient of the three options. It basically re-sorts and re-groups all of the rows in the grid.

    GetRowWithListIndex

Children
No Data