Click here to Skip to main content
15,891,033 members
Articles / Desktop Programming / Windows Forms

Saving Tree Structure using Serialization

Rate me:
Please Sign up or sign in to vote.
4.60/5 (4 votes)
22 Jun 2009CPOL5 min read 53.2K   1.7K   32  
This article demonstrates editing a tree structure and saving the job using serialization.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace ABSTreeSaver
{
    #region  DISCLAIMER
    /* THE CLASS IS PROVIDED "AS IS". ANY ECONOMIC (OR OTHERWISE) 
    /* LOSS/DAMAGE INCURRED DIRECTLY OR INDIRECTLY BECAUSE OF THIS 
    /* CLASS IS TO BE BEARED BY THE USER. THE AUTHOR IS IN NO WAY 
    /* RESPONSIBLE FOR ANY SUCH LOSS/DAMAGE.*/
    #endregion
    [Serializable]
    public class STreeNode
    {
        #region USER DEFINED VARIABLES
        string name=String.Empty;
        int imageIndex=-1;
        int selectedImageIndex = -1;
        string tag=String.Empty;
        string text = String.Empty;
        string toolTipText = String.Empty;
        List<STreeNode> nodes=new List<STreeNode>();
        #endregion
        #region PROPERTIES
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public int ImageIndex
        {
            get { return imageIndex; }
            set { imageIndex=value; }
        }
        public int SelectedImageIndex
        {
            get { return selectedImageIndex; }
            set { selectedImageIndex = value; }
        }
        
        public string Tag
        {
            get { return tag; }
            set { tag=value; }
        }
        public string ToolTipText
        {
            get { return toolTipText; }
            set { toolTipText=value; }
        }
        public string Text
        {
            get { return text; }
            set { text = value; }
        }
        public List<STreeNode> Nodes
        {
            get { return nodes; }
            set { nodes=value; }
        }
        #endregion
        public STreeNode()
		{
		}
        
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
Sid loves programming and has technical experience developing desktop based solutions using C#.Net, Winforms, WPF.
He has experience of Software services, I-Banks and Product development environments.
He also has a deep understanding of Product Development Lifecycle and Agile methodology of developing softwares.

Besides programming he is also fond of music, photography and cooking.
He lives in Bangalore.

Comments and Discussions