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
410
How do you: Bind To a Nested Object Property ~ Bi-Directional Binding
posted

How do you bind a control property to the property of a child object of a parent object and enable bi-directional synchronous object-control binding?

Client
     Address
        Address2

txtPhysAdd2.DataBindings.Add("Text", _Client.Physical, "Address2");

This line of code compiles just fine but does nothing because the property changed event is never fired as it is null... 

All controls bound to properties of the parent  _Client object fire and update just fine using the standard EventHandler callback using the conventional (property name)Changed event naming syntax...

The children of the main object will not play... 

 CW

Parents
No Data
Reply
  • 17259
    Offline posted

    Hi Carson,

    Even if this was working, the binding can't create an instance for _Client.Physical automatically when the user puts something in the control.

    I think you'd better use a BindingSource who is capable of inserting, but you might need to create an instance yourself (not sure).

Children