user2573117
user2573117

Reputation: 3

BindindSource Filter does not work

Please see the following code on a Winform Load method:

List<CustomersDTO> res = new List<CustomersDTO>();
res = _CustomerBO.GetCustomers();
customerBindingSource.DataSource = res;
customerDataGridView.DataSource = this.customerBindingSource;
customerBindingNavigator.BindingSource = this.customerBindingSource;

Now I want to filter on Searchbutton but I am not able to see filtered record on screen.

customerBindingSource.Filter = "Active = false";

I am missing something.. I did reasearch. Can anybody give me exact code example? I read about implementing IBindingList but not sure how to do that with my BindingSource..

Can anyone help?

Upvotes: 0

Views: 82

Answers (1)

Fung
Fung

Reputation: 3558

You don't have to implement IBindingList. You can construct a BindingList as the DataSource of your customerBindingSource. Like This:

customerBindingSource.DataSource = new BindingList<CustomersDTO>(res);

Upvotes: 2

Related Questions