Link to home
Create AccountLog in
Avatar of BigglesZX
BigglesZX

asked on

What is the correct way to serialize a Panel?

Hi all,

I've been struggling for the last hour trying to solve a problem in my C# application.

I have a "network diagram" form consisting of various controls placed on a Panel, and I am trying to implement save/load functionality for this diagram, so the state can be saved to disk and reloaded later.

I'm trying to achieve this through serializing the entire Panel instance - which I gather is not inherently serializable - to a binary file on disk. I have tried wrapping the Panel in a serializable wrapper class; and using Surrogates (which I don't fully understand), but have had no joy.

In addition, if possible could I be advised on the sanity of serializing an entire Form, as while writing this I realised that in addition to the Panel mentioned above, there are a couple of ArrayLists in the Form containing control data which I should probably also be saving.

I would really appreciate any help that could be offered on this as I'm working to an urgent deadline.

Thanks for reading; please request any additional information if required.

Biggs
ASKER CERTIFIED SOLUTION
Avatar of ShazbotOK
ShazbotOK
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of BigglesZX
BigglesZX

ASKER

ShazbotOK: I think you're right - since I posted the question I have spoken to a friend who agrees that XML would be better - if you don't mind I'll wait a bit to see if any other suggestions come up, otherwise points are yours.

I won't have a chance to work on this again for a day or two so please excuse any delay in assigning points.
Many thanks, sorry it took me so long to get around to this. I will try the XML route!