Saving complex properties of a windows forms component into a XML file (like Image,TabPage,etc.)?

Ö

Özden Irmak

Hello,

I'm trying to save some properties of some windows controls into a XML File.

Most of the properties work when I save them as String
(TypeConverter.ConvertToString). But some complex properties like image,
collections such as tabpage's cannot done with this method.

Anybody can help me on how to save and later restore the complex properties?

Thanks in advance...

Regards,

Özden
 
N

Nicholas Paldino [.NET/C# MVP]

Ozden,

I would try and use serialization to do this. You can use a
SoapFormatter to do this. The drawback to this is that the object has to be
marked as serialized. If this is not the case, you can try and use the
XmlFormatter. The drawback to this though is that it will only serialize
public properties, and some objects can not have their state fully restored
by just having the public properties set. For example, image data isn't
exposed publically (the raw bytes).

In these cases, you are going to have to serialize the data yourself in
some manner.

Hope this helps.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Image for example support ISerializable so it should be easy to serialize
it.

The problem are controls that do not support ISerializable , in fact all
controls has MarshalByRefObject in the inheritance line so they are not
serializables, you will have to do a custom serialization for them.

Cheers,
 
C

Cor

Hi Ozden,

Why do you not just look to the RESX files which are created when you use
the designer with VB.net forms and/or C# forms.

You have to open it and than look to it in the XML view.

If you use the imagelist from the designer on your form with some pics in it
you see also images

I hope this helps?


Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top