Click here to Skip to main content
15,921,276 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I have a little question to a problem I have

I have two listboxes listbox1 and listbox2

listbox1 has a datasource from bindingsource

listbox1.DataSource = dataBS;

and listbox2 is not binded

in listbox1 I have items:

1
2
3
4

i listbox2 I have added manually items
1
2
4


what I want to do is to with listobox2 items filter out listbox1 just to show those items from listbox2


I have tried a foreach statement like this

C#
foreach (object o in listBox2.Items)
                    {
                        DataBS.Filter = ("ID = \'" + (o + "\'"));
                    }


I always get the last item filtered
any help appreciated
Posted
Updated 9-Mar-13 0:11am
v2
Comments
Maciej Los 10-Mar-13 8:27am    
Do you know how loops[^] working? In the first loop, DataBS.Filter = 1; in the second, DataBS.Filter = 2 and in the third loop, DataBS.Filter = 4. So... finally, your filter is set to 4.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900