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??

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Is it the optimal way to achieve that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.