BindingSource filter ignored

James Buss 136 Reputation points
2021-07-24T20:52:36.647+00:00

I have a DataGridView. I set the DataSource to a BindingSource and the DataSource of the BindingSource is set to a DataTable. I set the Sort property and then the Filter property of the BindingSource. The DataGridView updates the display of the data accordingly. If I open a form to manipulate the data, when that form closes, I reload the data in the DataSource of the BindingSource, but the DataGridView displays all rows and not just the rows that the Filter property specified.

I've created a watch on the BindingSource.Filter property and I can see that the filter is still in the Filter property, so I don't understand why I get all records and not just the subset of records. And I don't understand why the filter works the first time the main form is displayed but it doesn't work when the data is refreshed.

The main form actually has two DataGridViews and two BindingSources and the one set works perfectly. It's only happening with the second set.

Developer technologies Windows Forms
Developer technologies VB
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.