G
Guest
I've got a situation where I have a DataGrid with a complex databinding to
an object. Something along the lines of:
datagrid.SetDataBinding( obj, "SomeProperty.List" );
....where obj has a property, "SomeProperty" that returns an instance of a
class with a property "List" of type IList.
My problem comes about when obj.SomeProperty changes to null. I get an
ArgumentNullException raised from the RelatedCurrencyManager that is bound to
my object when it tries to update obj.SomeProperty.List.
I can anticipate this happenning, so before the SomePropertyChanged event
gets fired, I try and clear the databindings on the data grid using:
datagrid.DataBindings.Clear();
This has no effect, the ArgumentNullException is still thrown.
I realized this is happenning because the CurrencyManger and PropertyManager
that were used in the binding still exist in my form's BindingContext, and
they're the ones actually throwing the exception. What I really need to do
is destroy those two binding managers when SomeProperty gets set to null.
Problem is, I can't, because all Clear/Remove methods are either protected
or internal.
Is there any way to remove a specific binding manager without clearing the
entire BindingContext?
I'm about to resort to setting the BindingContext of my form to null when I
need to clear the bindings....
Thanks,
Nathan Ernst
an object. Something along the lines of:
datagrid.SetDataBinding( obj, "SomeProperty.List" );
....where obj has a property, "SomeProperty" that returns an instance of a
class with a property "List" of type IList.
My problem comes about when obj.SomeProperty changes to null. I get an
ArgumentNullException raised from the RelatedCurrencyManager that is bound to
my object when it tries to update obj.SomeProperty.List.
I can anticipate this happenning, so before the SomePropertyChanged event
gets fired, I try and clear the databindings on the data grid using:
datagrid.DataBindings.Clear();
This has no effect, the ArgumentNullException is still thrown.
I realized this is happenning because the CurrencyManger and PropertyManager
that were used in the binding still exist in my form's BindingContext, and
they're the ones actually throwing the exception. What I really need to do
is destroy those two binding managers when SomeProperty gets set to null.
Problem is, I can't, because all Clear/Remove methods are either protected
or internal.
Is there any way to remove a specific binding manager without clearing the
entire BindingContext?
I'm about to resort to setting the BindingContext of my form to null when I
need to clear the bindings....
Thanks,
Nathan Ernst