使用 DataSet 过滤 DataGridview -> BindingSource,稍后添加额外的列
对于 WinForms VB.Net 应用程序,我使用 Bindingsource 的过滤功能来过滤数据,这在 DataGridview 中可见。 BindingSource 来自使用 Designer 创建的数据集,数据来自使用 JetEngine 和 .Net 3.5 的 Access DB。所以基本上:
Datagridview.Datasource = xxBindingSource
xxBindingsource.Filter = "[extended filter string with multiple columns]"
这个过滤工作正常,但是,现在我在 DataGridView 中包含了一些额外的列,我也想对其进行过滤。当然,当我将手动添加的列提供给 BindingSource 的过滤器时,这是行不通的。
我做了一些研究,但无法找到任何在 DataGridview 上使用 BindingSource 的过滤语法的方法。不过,我想使用这种语法,因为我设计了一个相当不错的 UserControl 和围绕它的类,以提供平滑、快速和简单的过滤功能。这里有什么建议吗?
另一种选择是重写这部分,并使用其他形式的过滤。谁能给我指出一些最佳实践吗?
For a WinForms VB.Net application, I use the Bindingsource's filtering capacity to filter data, which is seen in a DataGridview. The BindingSource is from a DataSet, created using the Designer, and the data comes from a Access DB, using JetEngine and .Net 3.5. So basically:
Datagridview.Datasource = xxBindingSource
xxBindingsource.Filter = "[extended filter string with multiple columns]"
This filtering works fine, however, now I included some extra columns in the DataGridView, which I'd like to filter on, too. Of course, when I feed the manually added columns to the Filter of the BindingSource, this doesn't work out.
I've done some research, and was not able to find any way to use the BindingSource's filtering syntax on the DataGridview. I'd like to use this syntax though, as I designed quite a nice UserControl and class around it, to provide smooth, fast and simple filtering capabilities. Any suggestions here?
Another option would be to rewrite this part, and use some other form of filtering. Can anyone point me to some best practices?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,杰克说得对!我了解了 DataColumn.Expression 以及向 DataSet 中的 DataTable 添加列,这不会影响 TableAdapter。所以我就这么做了。太好了,谢谢!
Actually, Jack got it right! I learned about the DataColumn.Expression and about adding a column to the DataTable in the DataSet, which didn't affect the TableAdapter. So I did just that. Great, thanks!