views:

63

answers:

1

I've been reading up on this whole subject, but I never came across this specific problem. I already understand that the whole idea of serializing an entire form is a horrible idea and just doesn't work. But, I am encountering a bit of a different problem. I have a class that inherits the "button" form object, that I call DataButton.

Now for my problem. I want to be able to serialize this class, but I don't need any of the information from the actual button class. Is there any way to bypass the fact that I can't set the button form object to Serializable() and notify VB that when serialization is to occur, it should simply skip over that information? Theoretically, if such a procedure were possible, I'd be able to do the entire serialization without a hitch.

I came up with the idea earlier of removing the "inherits" feature from the class, and having simply a button within the class, but that makes my program really difficult to work with as I am constantly changing the location, size, backgroundImage, text, and whatnot. Thus, immediate updates would be much tougher to work with.

Any help would be greatly appreciated.

+1  A: 

You mention the Serializable attribute, so I assume that you are talking about binary serialization. In this case, have your DataButton implement ISerializable and you will take complete control of serialization.

Look ISerializable up. It has only one method for serialization and assumes a specific constructor for deserialization (as constructor cannot part of an interface).

Timores
At first I saw your response as useless as I thought I had exhausted the possibility of that working. But, went back to it and got it all working correctly. Thanks for the standardized (yet very correct) response :)
AndyPerfect