A Parent Form with Multiple User Controls and databindings

A Parent Form with Multiple User Controls and databindings

Old forum URL: forums.lhotka.net/forums/t/8536.aspx


brannos posted on Tuesday, February 16, 2010

I have a multi-part form that utilizes several user controls (ie a user control to standardize the display and entering of an address or several uc that display different parts of a business object to simplify data-entry). The problem I am having is that I am passing the binding source to the user controls which in-turn has binding sources. When I save I then get the infamous edit level mis-match.

So my question is should I eliminate the child binding sources and bind the information another way?

If I should continue to use the child binding sources then how do I tell each part to stop what they are doing so the parent binding source can save the business object?

ajj3085 replied on Tuesday, February 16, 2010

This is how I handled it.

The user control has a bindingsource, which is setup more or less as a normal child bindingsource would be.  I then have various methods to do the databinding correctly.  A SetBindingSource sets the control's bindingsource.datasource to the root bindingsource, and the DataMember to the appropriate member of the BO.

The I have other methods / properties, like bool RaiseListChangedEvents, ResetBindings, EndEdit.  I creating these, which pass the call along to the control's bindingsource so that you can do the normal steps to avoid binding issues. 

HTH

Copyright (c) Marimer LLC