我有5个数据网格视图,每个数据视图有5到15列...
因此,我正在尝试将过滤过程自动化一点。但我就是不能让它工作!
I我的bindingSource使用实现可排序的BindingList:http://www.tech.windowsapplication1.com/content/sortable-binding-list-custom-data-objects
我已经搜索了一段时间,但我找不到为什么我可以设置bindingSource.Filter,但它什么也做不了:S
我已经找到了数据表或c#的示例,但还没有找到Vb.net和BindingSource的示例……
这是我创建绑定源的代码,我添加了过滤器作为测试,它通常不在这里。
Public Function reqTable(Of T)(ByVal pTable As String, ByVal pNoProjet As Integer,
Optional ByVal strAdditionnalConditions As String = "") As BindingSource
Dim lstRetour As New cclSortableBindingList(Of T)(New List(Of T))
Dim bsRetour As New BindingSource(lstRetour, "")
rsRequestCSV = conSQL.Execute("SELECT * FROM " & pTable & " WHERE NoProjet = " &
pNoProjet & " " & strAdditionnalConditions)
With rsRequestCSV
While Not .EOF
lstRetour.Add(Activator.CreateInstance(GetType(T), New Object()
{rsRequestCSV.Fields})) 'New clsTable(rsRequestCSV.Fields))
.MoveNext()
End While
End With
bsRetour.Filter = "Quantite < 3"
Return bsRetour
End Function
发布于 2012-08-11 00:39:23
为了使用BindingSource.Filter
,底层列表(cclSortableBindingList
)需要实现IBindingListView
接口。BindingList
不实现此接口。
请参阅MSDN中的BindingSource.Filter Property 。
https://stackoverflow.com/questions/11904820
复制相似问题