Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
490
Updating an unbound column
posted

I have a scenario where I am binding an object to my grid that contains a property that is another object. Then I am adding the second object's properties to the grid as unbound columns. Something like this:

Object1.ID

Object1.Object2

Object1.Name

 

Object2.State

Object2.City

 

So, for the above case my grid would have bound columns of ID and Name.  It would also have unbound columns of State and City.

When the underlying object (Object1) is changed, the grid automatically becomes aware of this and my cell text us updated with the new value (like if I change the Name property).  However, if the Object2 property of Object1 is changed... like changing the value of the "State" property, the grid will not update with the new value.  I am thinking this is because I made State an unbound column.  That makes sense to me.

My question is what event can I subscribe to in order to know when to refresh my unbound columns?  I am using a binding source with my grid, so I thought I could listen for the ListChanged event or something.  This did not fire when my property changed though.  How does the bound column know to update when I make that change there?

Thanks!

Steve

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi Steve,

    The grid gets notifications of changed fields from the BindingManager and I don't see how the BindingManager could possible recognize either of these changes, unless you are somehow sending it notifications via an interface like IBindingList or INotifyPropertyChanged.

    Are you binding the grid to a single instance of Object1 or some kind of list? I suspect you must be using a List<Object1> or BindingList<Object1>. If you are using one of these and your objects fire events when the properties change, then the BindingManager could detect this. If not, then I'm not sure what's going on there.

    But it's hard to tell with so little information about the objects and what you are actually binding to.

Reply Children