StrataFrame Forum

Designer serialization

http://forum.strataframe.net/Topic6330.aspx

By Chan - 1/27/2007

Hi,



When I drop ChildFormDialog control on form, it will "auto generate code below at designer.cs.



This.ChildFormDialog1.ParentForm = this;




For curiousity, I created a class to "subclass" ChildFormDialog component using association which able to drop on usercontrol..

I would like to auto generate code below when drop to user control.



This.ChildFormDialog.ParentForm = this.ParentForm;




However, It doesnt't work. It always give me code below.



This.ChildFormDialog.ParentForm = null;




How to do this?



My Current Code



[Browsable(false)]

public BaseForm ParentForm

{

get

{

if (_ParentForm == null && this.DesignMode)

{

IDesignerHost loDesigner = (IDesignerHost)this.GetService(typeof(IDesignerHost));



if (loDesigner != null)

{

if (!loDesigner.RootComponent.GetType().IsSubclassOf(typeof(MicroFour.StrataFrame.UI.Windows.Forms.UserControl))

&& loDesigner.RootComponent != this)

{

return _ChildFormDialog.ParentForm;

}

else

{

MicroFour.StrataFrame.UI.Windows.Forms.UserControl loUC = (MicroFour.StrataFrame.UI.Windows.Forms.UserControl)loDesigner.RootComponent;

return (BaseForm)loUC.ParentForm;

}

}

}



return this._ChildFormDialog.ParentForm;

}

set

{

_ParentForm = (BaseForm)value;

this._ChildFormDialog.ParentForm = (BaseForm)value;

}

}



By Trent L. Taylor - 1/27/2007

Chan,

This goes beyond a simple post or reply.  You are getting into serialization within the designer which takes a good amount of explanation. 

You have to define the this when the control is dropped.  Since you have purchased StrataFrame, you also have the source code for reference purposes.  I recommend looking at the UserControl object and then looking at the SyncObject property.  This will at least get you started.