ARACK04
asked on
changing datasource
I have a listbox which has a datasource set to a List collection.
I'm trying to remove an item from the List, and then reload the listbox - expecting to see the removed item no longer present in the listbox. Here is the code to do that:
source.RemoveAt(0);
listBox1.DataSource = source;
listBox1.DisplayMember = "str";
For some reason the listbox remains the same after I execute this code. I know the code is getting reached since if I execute it enough times, an exception is raised, since there are no more items left to remove from the List. Thannks!
I'm trying to remove an item from the List, and then reload the listbox - expecting to see the removed item no longer present in the listbox. Here is the code to do that:
source.RemoveAt(0);
listBox1.DataSource = source;
listBox1.DisplayMember = "str";
For some reason the listbox remains the same after I execute this code. I know the code is getting reached since if I execute it enough times, an exception is raised, since there are no more items left to remove from the List. Thannks!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.