Reputation: 140
I have 5 datagridviews, with 5 to 15 columns each...
So I'm trying to automate the filtering a little bit. But I just can't get it to work at all!
I My bindingSource uses A BindingList implementing Sortable : http://www.tech.windowsapplication1.com/content/sortable-binding-list-custom-data-objects
I've searched for a while but I can't find why I can set bindingSource.Filter, but it doesn't do anything :S
I've found examples for datatables or c# but I havent found some for Vb.net and BindingSource...
Here's my code where I create the binding soure, I've added the filter as a test, it ususlly isn't here.
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
Upvotes: 0
Views: 2463
Reputation: 4354
In order to use the BindingSource.Filter
, the underlying list (cclSortableBindingList
) would need to implement the IBindingListView
interface. A BindingList
doesn't implement this interface.
See BindingSource.Filter Property from MSDN.
Upvotes: 1