ancdev
ancdev

Reputation: 207

Windows Forms DataGridView DataSource

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

Answers (1)

Ε Г И І И О
Ε Г И І И О

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

Related Questions