Eric Burley [mailto:[EMAIL PROTECTED]] wrote:

> I've got a form which implements ISerializable.  It contains
> custom controls that implement Iserializable as well.  I can
> serialize those controls in the GetObjectData method on the
> form.  The problem comes when I try to handle the
> Deserialization constructor on the form.  I have to call
> InitializeComponent, where the designer generated code does
> it's thing (namely creating the controls, positioning them,
> etc).  After calling that, I'd want to deserialize the custom
> controls; however, they've already been created and
> positioned (they only serialize a subset of their
> information, so I need the designer code to position them.),
> and I'd be creating them again.  I don't want my form to know
> what information the custom controls are serializing, so I
> can't just serialize the settings for the controls.  I also
> don't want to modify the InitializeComponent function,
> because I don't want to lose the ability to modify the form
> in the designer.  Any suggestions?

Sounds great and you could totally do it, but I think you're out of luck if
you want to continue to use the designer with this approach since the
designer expects to be able to control the instantiation of the child
controls and, as you pointed out, you would need to do that. If there were
some way to tell the designer not to worry about the instantiation then all
would be well because you would rehydrate the controls first in construction
and call InitializeComponent when you were done. Hmm... after a quick look
at the designers I just can't see a way to make this work unfortunately,
that's not to say it can't be done, just to say it can't be done easily.

Later,
Drew
.NET MVP

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to