BindingSource.Filter 排除值 - 如何?

发布于 2024-07-12 03:59:14 字数 223 浏览 9 评论 0原文

我的 BindingSource 绑定到对象集合(不使用 ADO.NET),我想过滤它并排除一些值,但不确定我是否正在使用它,因为我期望的结果集不会返回。 我在想这样的事情,但它不起作用:

MyBindingSource.Filter = "State = 'NY' AND State = 'MA' AND State = 'CO'";

任何帮助将不胜感激!

My BindingSource is bound to a collection of objects (not using ADO.NET) and I would like to filter it and exclude some values but not sure if I'm using this exactly since the result set I am expecting is not coming back. I was thinking something like this, but its not working:

MyBindingSource.Filter = "State = 'NY' AND State = 'MA' AND State = 'CO'";

Any assistance will be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡看悲欢离合 2024-07-19 03:59:14

您已经使用过 AND。

如果您希望过滤器正常工作,您需要这样:

MyBindingSource.Filter = "State = 'NY' OR State = 'MA' OR State = 'CO'";

布尔值中的某些内容不可能同时处于两种状态。 (至少在我工作的逻辑领域......)

You've used AND.

If you want your filter to work you want this:

MyBindingSource.Filter = "State = 'NY' OR State = 'MA' OR State = 'CO'";

There is no way that something in boolean can be in two states at the same time. (At least in logic realms I work in anyway...)

王权女流氓 2024-07-19 03:59:14

我从未在 WPF 世界之外尝试过它,但您可以查看 ListCollectionView(对于 IList)/BindingListCollectionView(对于 IBindingList)。 它应该引发必要的事件,并且您可以在没有基础列表的情况下使用过滤器。

I never tried it outside of the WPF world, but you could take a look at the ListCollectionView (for IList)/BindingListCollectionView (for IBindingList). It should raise the necessary events, and you can use the filter without the underlying list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文