简体   繁体   中英

Why aren't bound DataGridView cells being updated?

I have successfully bound my DataGridView to a list. But, the grid doesn't refresh when I programatically change some of the properties of one of the objects within the list. If I click in the cell (or minimize and then maximize form), the displayed value is refreshed.

I read here that I should use a BindingList. The list I am using is an interface type which doesn't implement IBindingList. But, the concrete type being used to initialize the list does inherit off of BindingList. Any ideas?

Your list must implement IBindingList (or be a BindingList ) and your object must implement INotifyPropertyChanged . Both conditions are required for your DataGridView to bind properly.

So if your data source would be, for instance, MyList<MyClass> , MyList must implement IBindingList and MyClass must implmenent INotifyPropertyChanged .

Here is a neat example: http://crazorsharp.blogspot.com/2009/06/inotifypropertychanged-how-to-and-when.html

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