I posted this a couple of days on the dotnet-winforms forum, but noone
picket it up. Seems to be unudsual.
IU ahve problems with databinding not working in a "hierarchy of user
controls".
Let me decrube what we do: I work at the moment on databinding
infrastructure for our business object toolkit, as well as some complex
editors for it. For this, we split all forms into a lot of user
controls, and it is pretty normal to have a user control embed another
user control.
A good sample would be this: There is (lets talk about editing schemata)
something called an EntityObject (which has a shcema that has a number
of properties that are classes themselves). One of these is an
EntityobjectInfo (schema element). So, we go ahead and make a user
control for editing an EntitObjectInfo schema element, and then embedd
it into the user control that is the editor for the EntityObject. In
reality things ae a little more complicated (not all elements have
embedded eitors et al), but the idea is basically to have editors for
the classes.
NOW - here is the problem:
* For the EntityObjectInfo object, I created an editor
(EntityObjectInfoEditor). This has a property where an EntityObjectInfo
is assienged to, then it is put into a component that is a DataSource
(an IBindingList, actually), and some controls are bound to it. Lets
just assume (Simplest case), that there is just a datagrid that gets
bound to the IBindingList, and is not configured, so the properties of
the EntityObjectInfo should show.
* For the EntityObject there is an edtir (EntityObjectEditor) that has
an embedded EntityObjectInfo editor. The EntityObjectEditor gets
assigned an EntityObject, and puts this EntityObject's ENtityObjectInfo
into the property of the Eembedded EntityObjectInfoEditor.
NOW - here thigns start to go awry. Databinding in the EntityObjectInfo
editor just does not work.
We made a testbed and put three controls onto it:
* A databrid for using direct binding. Putting the EntityObjectInfo into
an array (new EntityObjectInfo [] {variable}) resulted in correct
databinding.
* An Instance of the ENtityObjectInfoEditor - setting the Editor's
EntityObject results inthe grid show ing the data.
* An Instance of the EntityObjectEditor Setting th eEneityObject there
reyusults in the correc tassignment to the inner editor (the
EntityObjectInfo editor), BUT - databinding just does not show up.
Naturally, this has brought development to a screaming stop. VERY funny.
I played around with some things, like creating my own BindingContext in
the EntityObjectEditor and EntityObjectInfoEditor, but somehow I dont
get the clue why databinding fails on the inner user control.
Anyone has an idea for this?
Thomas Tomiczek
THONA Software & Consulting Ltd.
(Microsoft MVP C#/.NET)