BindingSource.Filter 排除值 - 如何?
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已经使用过 AND。
如果您希望过滤器正常工作,您需要这样:
布尔值中的某些内容不可能同时处于两种状态。 (至少在我工作的逻辑领域......)
You've used AND.
If you want your filter to work you want this:
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...)
我从未在 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.