Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Serialiization of an object that inherit from a tabpage object.

Posted on 2010-01-12
Medium Priority
Last Modified: 2012-05-08
In my winform app. I have to serialize an object that inherit from TabPage object.
I got a message that I have to mark the TabPage as [Serializable] too.
How can I do this?
    partial class myTabPage : TabPage
        public string ContainerTableTag;
        public bool showAlways;
        public bool showForAllChildren;
        public bool showForChild;
        public myTabPage()

Open in new window

Question by:yaron89
  • 2
  • 2

Expert Comment

ID: 26300562
What information do you need to serialize inside of the tabpage control itself? Do you know this before-hand or only at runtime?

Author Comment

ID: 26301630
The information I need is some boolean and strings varaibles in myTabPage.
The values accepted only at runtime.
I can try to  seperate the varaibles to another class, however I would like to know if there ia an option to serialize the control as it is, or not.

Accepted Solution

DaveJellison earned 2000 total points
ID: 26301695
You can't really serialize/deserialize controls as-is because of the nature of the beast. Controls have things that change at run time like windows handles, etc. and things that change at design time such as you changing the width of that textbox in the designer. Serialization is not all "all-or-nothing" approach though so I can understand what you want to do. You're trying to serialize what makes sense...your properties such as
        public string ContainerTableTag;
        public bool showAlways;
        public bool showForAllChildren;
        public bool showForChild;
..and that's a perfectly good approach. Unfortunately, since this isn't a control you have total control over because of your inheritance of TabPage you can't (easily) inject a [Serializable] attribute into the TabPage control itself because, obviously you don;t have the source code.

What you can do rather than writing a separate class to contain your properties is inherit the ISerializable interface in your myTabPage and by implementing that interface you can "choose" what and how you want to serialize in your class (and leave the rest alone)


is a good first-look at using ISerializable and should help you out with the few properties that you need to serialize. Let me know if you need any further assistance with the sample.

Happy Coding


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question