Re assign grid source to updated list of objects and call databind method again.
Refresh a DataGridView on update to its list data source
-
18-07-2023 - |
سؤال
In my current implementation I'm using a data grid view that is fed from a list of objects. I'm trying to add new entries, by adding new objects to the list.
I'm finding that when these new entries are added to the list, they do not appear in the DataGridView. I've tried updating it, clearing it and refilling it. All to know avail.
Any help would be greatly appreciated.
This was solved by using a binding source like so.
Dim bs As New BindingSource
bs.DataSource = Entries
DataGridView1.DataSource = bs
And then reassigning the data source each time.
Public Sub Grid_Update()
bs = New BindingSource
bs.DataSource = Entries
DataGridView1.DataSource = bs
End Sub
المحلول
لا تنتمي إلى StackOverflow