I fill ArrayList with instances of the same class (let's call it Product), and associate it with DataGridView.DataSource.

arrlProducts = New ArrayList arrlProducts.Add(product) arrlProducts.Add(product1) dtgrw.DataSource = arrlProducts 

In the table itself, the necessary formatting of the cells is specified, the columns are marked on the Product properties. Everything is beautiful.
But as the list progresses, the list changes — elements are removed or added from it, and therefore the table needs to be updated.
I tried to override the DataSource property - it still shows everything as before.
I tried this:

 dtgrw.DataSource = Nothing dtgrw.DataSource = arrlProducts 

The table was updated in accordance with the list, but it took down all the settings of the table columns - the font, the names of the columns, adding columns based on the Product properties.
How to update the table correctly if the data source is updated?

    2 answers 2

    For automatic synchronization of the display with the collection, it is recommended to use collections that implement IBindingList. This is usually a DataView or BindingList.

      Understood himself. It was necessary to set the dtgrw.AutoGenerateColumns = False option