BindingSource and Parent - Child forms interaction

BindingSource and Parent - Child forms interaction

Old forum URL:

Lazaro posted on Monday, January 31, 2011

I have a doubt related with BindingSource


I have a main form where one of the controls it contains is a grid, and from this grid you can open a dialog to edit one of its elements (edit a child object). Changes in the child object causes changes in the parent object as well (in main form).

Main form: LoanSetupForm (Root Object: LoanSetup and Child Collection: WorkUnits)

Dialog: WorkUnikForm (Child Object: WorkUnit)

When the dialog form opens, I have to call:




When the dialog form closes I have to call:

ParentForm.LoanSetupObj.ApplyEdit() or ParentForm.LoanSetupObj.CancelEdit()



I am wondering if there is a better way to call BeginEdit() on a root object after bound (from a child object/form) because I have to expose the unbind and rebind to other forms to be able to accomplish this. This approach seems as an overkilled, especially if the child object were to be editable in the grid (and I would have to do this when getting into one line of the grid).

RockfordLhotka replied on Monday, January 31, 2011

Prior to CSLA 4 it was not possible to bind one object to more than one Windows Forms binding source, because the IEditableObject implementation wouldn't support the concept.

In CSLA 4 the one major enhancement for Windows Forms was to update this implementation so it is possible to bind one object to more than one binding source.

JonnyBee replied on Tuesday, February 01, 2011

But, there's just a few lines of code that needs to be changed in Csla.Core.BusinessBase so I could easily "downport" this from Csla 4 to Csla 3.8.4 beta.

Lazaro replied on Tuesday, February 01, 2011

My question was really about having to unbind because I had to call the BeginEdit in the root object not because I had to bind the same objects with other controls, which is also true.

JonnyBee replied on Tuesday, February 01, 2011

When you say Dialog you actually mean a Modal Form - owned by the parent form?

What type of changes are done to the parent object when you edit a child?

The challenge is to maintain a correct EditLevel on you object graph and maintain a predictable series of Begin/Apply/Cancel and if DataBinding is active in the MainForm you really have little control on when BeginEdit/ApplyEdit or CancelEdit is called unless you do an unbind/rebind. 

If you have a modal dialog I'd prefer to keep the Unibind/Rebind as private methods in your MainForm.

And the properties that are set in Parent cold possible be reset by BusinessRules when a ChildChanged event occurs (and thus maintained by the root object only). That way you would only have to worry about BeginEdit/CancelEdit/ApplyEdit on the child object.

Copyright (c) Marimer LLC