question

JamesBuss avatar image
0 Votes"
JamesBuss asked ZhanglongWu-MSFT commented

BindingSource filter ignored

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.

dotnet-visual-basicwindows-forms
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi James,

You're going to have to show some of your code. Since one grid's binding filter works correctly and the other doesn't, you're probably doing something differently ... maybe setting the filters in different methods or events.

But, without seeing some of your code, it's impossible to guess as to what could be wrong.


~~Bonnie DeWitt [MVP since 2003]
http://geek-goddess-bonnie.blogspot.com


0 Votes 0 ·

Hi @JamesBuss,

As Bonnie mentioned, it would be better to resolve the issue if you can show the code which we can reproduce the issue on our side.


Best regards,
Zhanglong

0 Votes 0 ·

0 Answers