Why are the DataGridView cells not bound?

I have successfully bound my DataGridView to a list. But the grid does not update when I programmatically change some properties of one of the objects in the list. If I click on a cell (or hide and then enlarge the shape), the displayed value will be updated.

I read here that I should use a BindingList. The list I'm using is an interface type that does not implement an IBindingList. But the specific type used to initialize the list inherits a BindingList. Any ideas?

+8
c # winforms binding datagridview
source share
1 answer

Your list must implement an IBindingList (or be a BindingList ), and your object must implement INotifyPropertyChanged . Both conditions are necessary for the correct binding of the DataGridView.

So, if the data source is, for example, MyList<MyClass> , MyList should implement IBindingList and MyClass should impliment INotifyPropertyChanged .

Here's an example: http://crazorsharp.blogspot.com/2009/06/inotifypropertychanged-how-to-and-when.html

+9
source share

All Articles