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
2197
Displaying newly added rows in the UltraWinGrid when bound to a List<T>.
posted

When the UltraWinGrid is bound to a List<T> and new item is added to the list, you need to call the UltraGrid.Rows.Refresh method so that the newly added object shows up as a row in the grid. So, if we have this:

List<Product> products = new List<Product>();
ultraGrid1.DataSource = products;

We will see columns representing all of the public properties in the grid, however no rows will exist because we have not added any objects to the list yet. If we add a button to the form, handle its click event and then do this:

Product p = new Product();
products.Add(p);

We still won't see a new row in the grid. We have to call the Rows.Refresh method to cause the new row to appear:

this.ultraGrid1.Rows.Refresh(RefreshRow.ReloadData):

The reason for this is because the List<T> does not raise change notifications like the BindingList<T> does. When using a BindingList<T> it is not necessary to call Rows.Refresh() to display the newly added object in the grid.

Sincerely,
Charlie
Senior Developer Support Engineer
MCTS