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
235
InitializeRow not fired when adding recycled items
posted

Hello,

Using an Ultragrid bound to a typed Binding list, if i clear the binding list then re-add items back to the binding list, including some of the original items, then i am not getting the InitializeRow event fireing for the rows that are being recycled if the grid is not visible during the refresh.

Any ideas?

Thanks

Steve

Parents
  • 469350
    Offline posted

    Hi Steve,

    When you say "including some of the original items", are you saying that you are removing an item from the list and then adding the exact same instance of that item back into the list? If it's the same instance, than the grid is probably re-using the existing UltraGridRow object as an optimization, so it thinks that it doesn't need to re-initialize the row.

    This might be a bug, but it might not. If the grid hasn't thrown away that row, then my guess is that you are clearing the BindingList and then re-adding the rows in a synchronous operation, which means as far as the grid is concerned, the row was never really removed. The grid responds to the BindingList notifications asynchronously. So if you remove a row and re-add it, the grid just marks the rows collection dirty and then updates the collection the next time the grid paints. So it's essentially one operation and since the same row with the same ListObject existed before and after the operation, it's basically treated like a no-op.

    If you need to force InitializeRow to fire, then you have a couple of options. One thing you could do is force the grid to refresh after you remove all of the rows. You could do this pretty easily by calling grid.Update to force the grid to paint. This will have to effect of making the removal of the rows a synchronous operation. The grid will process the removal of the rows and then when you re-add the row(s), there should be no caching and the grid should treat every row as a new row.

    Another option is to just keep doing what you are doing and then after you have added all of the rows you need, you can call grid.Rows.Refresh(FireInitializeRow) to make the grid fire the InitializeRow event for every row.

     

Reply Children
No Data