简体   繁体   中英

C# Listbox Bound to Entity "Entity Framework"

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM