Cannot save custom ListBox to disk.

aewarnick

Well-known member
Joined
Jan 29, 2003
Messages
1,031
[Serializable]
public class ImageLB : ListBox
{}

That is my custom ListBox class. When I create a new instance of it and try to save it using the BinaryWriter it says ListBox is not serializable.

I want to save my entire ListBox (ImageLB) to disk with all its items and properties. Is this possible?
 
With some more testing I am guessing that everything within the class must be Serializable. So what I am trying to do is not possible.

If not correct post back.
 
You will need to extract the data from the Items collection and put it in your own serializable collection, then serialize that. No part of the ListBox is serializable as-is.
 
Youre saying I need to take it apart and put it back together? A small explanation of how to strip it and put it back together would be helpful. Just so I have some direction. If you would, VolteFace.
 
What was I thinking! All I have to do is save the Items property to disk! That is all I need! Thanks VolteFace.

Although that does not work unless I first put the items into my own Array and save them. No problem though.
 
Back
Top