Filter a list using FilteredBindingList

Filter a list using FilteredBindingList

Old forum URL:

Blerina posted on Monday, April 08, 2013

I use the csla.FilteredBindingList to fill a combobox in my windows form. I choose the option "Use data Bounds" of the combobox and i link it to a database table(Office), then i use the FilteredBindingList method to filter the list. Here is my code.

 _accessibleOffices = OfficeList.GetAll


Sub filterAccessibleOffices()


            Dim mFiltered As New Csla.FilteredBindingList(Of Office)(_accessibleOffices)

            mFiltered.FilterProvider = AddressOf Filtersoffice

            mFiltered.ApplyFilter("", _OfficesAccess)

          OfficeListBindingSource.DataSource = mFiltered

        Catch ex As Exception

            MsgBox( ex.Message)

        End Try

    End Sub

    Private Function Filtersoffice(ByVal item As Object, ByVal filterValue As List(Of Integer)) As Boolean

        Dim result As Boolean = False

               ....some variable declarations

                For Each office As OfficeInfo In officeList

                    If filterValue.Contains(office.OfficeId) Then

                        result = True

                        Return result

                    End If


        Return result

    End Function

This code works fine, but for some purposes in my project, i would like to filter the _accessibleOffices list i use as the parameter of the FilteredBindingList. I realised that this method doesnt update this list, it remains the same. I tried this code in the FilteredBindingList method

_accessibleOffices = mFiltered

but it wasn't possible as a conversion.

Any kind of help to achieve my purpose would be very grateful.

Copyright (c) Marimer LLC