0

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
4

1 に答える 1

1

を使用するBindingSource.Filterには、基になるリスト ( cclSortableBindingList) でインターフェイスを実装する必要がありIBindingListViewます。ABindingListはこのインターフェースを実装していません。

MSDN のBindingSource.Filter プロパティを参照してください。

于 2012-08-10T16:39:23.333 に答える