本文介绍了BindingSource到DataTable的转换-筛选器不起作用.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将要过滤的BindingSource转换为DataTable,以便可以将每个条目放置在报表的富文本框中.
我已经弄清楚了如何将BindingSource转换为Datatable,以便可以执行此操作.但是现在过滤器不起作用,将不胜感激.
Hi,
I''m converting a BindingSource which is being filtered into a DataTable so that each entry can be placed in a rich text box for a report.
I have figured out how to convert the BindingSource into a Datatable so that I can do this. But now the filter doesn''t work, any help will be appreciated.
Dim dt As DataTable = New DataTable()
QryMaintenanceBindingSource.Filter = "Site like '" & cmbSite.Text & "'"
dt = CType(QryMaintenanceBindingSource.DataSource.Tables(QryMaintenanceBindingSource.DataMember), DataTable) 'Don't know why or how this works.
DataGridView2.DataSource = dt
DataGridView2.Update()
DataGridView2.Refresh()
在此先感谢
Marco
Thanks in advance
Marco
推荐答案
Dim dt As DataTable = New DataTable()
Dim myDataView As New DataView(dt)
myDataView.RowFilter = "Site like '" & cmbSite.Text & "'"
myDataView.Sort = "Site" 'If you like
DataGridView2.DataSource = myDataView
这篇关于BindingSource到DataTable的转换-筛选器不起作用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!