BindingSource Filter and Find ?

Jess31 used Ask the Experts™
I have a Bindingsource, bound to a DataTable, and has a filter set (BS.Filter="DayOfWeek=5"). When I do a BS.Find it seems that is is searching (and returning) also rows that that outside the filter. Is this the way .Find works or am I doing something wrong? If this is the way .Find is meant to work is there another way of searching that will adhear to the Filter?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Miguel OzSenior Software Engineer
Top Expert 2009

BS.Filter="DayOfWeek =' 5'".
You are missing the single quote. Check:


If you want your filter to work you want this:

MyBindingSource.Filter = "State = 'NY' OR State = 'MA' OR State = 'CO'";

Could you please post a code snippet? BS Find searches ar based on PropertyDescriptor not just column name.

PropertyDescriptorCollection pdc = bs.CurrencyManager.GetItemProperties();
bs.Position = bs.Find(pdc["my_column_name], my_searchable_value);
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Miguel OzSenior Software Engineer
Top Expert 2009

Please specify if you are binding using the property designer or manually.


I'm not missing a single quote, this is a numeric column.

I using code to filter, here is the code:

BSCustomerPossibleRoutes.Filter = "DayOfWeek=" & CType(DaysDates.DayOfWeek(DateTimePicker2.Value), String)

here the BS is setup:
BSCustomerPossibleRoutes = New BindingSource
BSCustomerPossibleRoutes.DataSource = DSCustomerPossibleRoutes
BSCustomerPossibleRoutes.DataMember = "CustomerPossibleRoute"


when doing
bs.position = bs.find
is it searching only the filtered set or the whole set, and what does it return if it finds nothing?

If it find nothind it returns -1 - and this is valid postion for setting bs.Position = as it points to "No Current record".

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial