Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListBox doesn't show changes to DataSource

I thought this was a simple problem, but I can't find any information on the web. I'm binding a ListBox to a List using BindingSource like so:

List<Customer> customers = MyMethodReturningList();

BindingSource customersBindingSource = new BindingSource();
customersBindingSource.DataSource = customers;

customersListBox.DataSource = customersBindingSource;

Now, when I add or delete from customers list, my ListBox gets updated (even without using ResetBindings on BindingSource), but if I change any of the customer objects in the list, it does not. Calling ResetBindings has no effect. I even implemented my own BindingList, but the behaviour hasn't changed.
The Customer class uses properties for accessing and modification of data. Its ToString() content is displayed in the list.

I'm using C# in .Net 2.0.

Any ideas?

Thanks

like image 481
Błażej Czapp Avatar asked Oct 22 '09 19:10

Błażej Czapp


1 Answers

If you use a BindingList you don't even need the BindingSource:

BindingList<Customer> customers = new BindingList<Customer>(MyMethodReturningList());
customersListBox.DataSource = customers;
like image 150
Chuck Wilbur Avatar answered Oct 05 '22 18:10

Chuck Wilbur