Reputation: 207
How do i get a datagridview in a windows forms application to refresh when a assign it to a new list or collection? My code consists of initializing a list and assign it to the datagridview datasource which works great, and upon clicking a button to search, i'm filtering the list using linq and re-assign it to the datasource, however nothing changes, the datagridview remains showing the initial result.
Upvotes: 0
Views: 931
Reputation: 12381
Don't use a List
. Use a BindingList
.Then the datagridview will automatically update itself when the list is updated. You just have to call .Refresh() on your datagridview.
Upvotes: 1