Data binding a DefaultView to DataGridView and INotifyPropertyChanged not working?

Posts   
 
    
heerser avatar
heerser
User
Posts: 36
Joined: 15-May-2005
# Posted on: 14-Jul-2015 17:16:08   

Hi there, I'm still using v2.6 and have a question about data binding a Default View to a Win forms DataGridView: When there is a property in the underlying entity that is changed the changes are not immediately visible in the datagrid. Only after I navigate to the concerned cell. When I first copy the elements from the DefaultView to a BindingList<T> the changes will be immediately visible in the datagridview. I beleive the datagridview is looking to the bool IRaiseItemChangedEvents.RaisesItemChangedEvents before subscribing to INotifyPropertyChanged.PropertyChanged(?) and the RaisesItemChangedEvents of a DefaultView returns false in my case..

Any ideas? many thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 14-Jul-2015 18:48:43   

Are you using a BindingSource control?

heerser avatar
heerser
User
Posts: 36
Joined: 15-May-2005
# Posted on: 14-Jul-2015 19:48:47   

What do u mean with a BindingSource?

I bind the defaultview to the DataSource prop of a datagrid:

DataGridView.DataSource = SomeEntityCollection.DefaultView;

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 14-Jul-2015 20:41:59   

In VS.NET 2005, you can still directly bind an EntityCollection to a grid control, but it's recommended to use a BindingSource control, which is new in .NET 2.0. To setup a .NET 2.0 DataGridView control, not only drag the EntityCollection onto your form but also a BindingSource control. You then set the DataGridView's DataSource property to the BindingSource control and the BindingSource' DataSource property to the EntityCollection dragged onto the form. The EntityCollection class then doesn't have a factory set so use the the smart-tag on the EntityCollection on the form to configure the collection which will show the EntityCollection's designer. After you've selected the factory to use, you should see the DataGridView setup with the columns of the entity type contained in the bound EntityCollection.

The above is quoted from the documentation

heerser avatar
heerser
User
Posts: 36
Joined: 15-May-2005
# Posted on: 14-Jul-2015 20:56:07   

it works thanks!!

smile smile smile smile

RTFM men RTFM (sorry)