views:

830

answers:

2

On my WinForm, I bound my listbox to a Table in Entity on EDMX, but when the table data is changed, I tried to call

myListBox.DataSource = Entities.table;
myListBox.ResetBindings();
myListBox.Refresh();

but nothing happens in ListBox. The Entities.table object holds the right data though, it just doesn't reflect on the ListBox.

Any idea??

+2  A: 

Try the following

myListBox.DataSource = null;
myListBox.DataSource = Entities.table

There is an optimization in the ListBox, and other data binding classes, that basically will not do an update if the reference assigned to DataSource does not change. It does not actually do inspection on the contents of the data. Setting it to null before hand will guarantee that the reference is different.

JaredPar
A: 

Is it the optimal way to achieve that?

SuperJMN