Jess31
asked on
BindingSource Filter and Find ?
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?
Hi
If you want your filter to work you want this:
MyBindingSource.Filter = "State = 'NY' OR State = 'MA' OR State = 'CO'";
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.
Like:
PropertyDescriptorCollecti on pdc = bs.CurrencyManager.GetItem Properties ();
bs.Position = bs.Find(pdc["my_column_nam e], my_searchable_value);
Like:
PropertyDescriptorCollecti
bs.Position = bs.Find(pdc["my_column_nam
Please specify if you are binding using the property designer or manually.
ASKER
I'm not missing a single quote, this is a numeric column.
I using code to filter, here is the code:
BSCustomerPossibleRoutes.F ilter = "DayOfWeek=" & CType(DaysDates.DayOfWeek( DateTimePi cker2.Valu e), String)
BSCustomerPossibleRoutes.R esetBindin gs(False)
here the BS is setup:
BSCustomerPossibleRoutes = New BindingSource
BSCustomerPossibleRoutes.D ataSource = DSCustomerPossibleRoutes
BSCustomerPossibleRoutes.D ataMember = "CustomerPossibleRoute"
question/problem:
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?
I using code to filter, here is the code:
BSCustomerPossibleRoutes.F
BSCustomerPossibleRoutes.R
here the BS is setup:
BSCustomerPossibleRoutes = New BindingSource
BSCustomerPossibleRoutes.D
BSCustomerPossibleRoutes.D
question/problem:
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BS.Filter="DayOfWeek =' 5'".
You are missing the single quote. Check:
http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.filter.aspx