Click here to Skip to main content
15,891,184 members
Articles / Programming Languages / C#

Windows Forms - Creating and Persisting Custom User Settings in C# - Part 2

Rate me:
Please Sign up or sign in to vote.
4.45/5 (6 votes)
9 Sep 2008CPOL3 min read 27.7K   593   20  
This article discusses the creation and persistence of .NET Framework and custom objects within the Windows User Settings.
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace CustomUserSetting2
{
    #region Week Class

    [Serializable]
    public abstract class Week
    {
        private string _controlName = string.Empty;
        private bool _controlEnabled = false;

        public Week(string controlName, bool controlEnabled)
        {
            _controlName = controlName;
            _controlEnabled = controlEnabled;
        }

        public string ControlName
        {
            get
            {
                return _controlName;
            }
        }

        public bool ControlEnabled
        {
            get
            {
                return _controlEnabled;
            }
            set
            {
                _controlEnabled = value;
            }
        }
    }

    #endregion Week Class

    #region CheckBoxControlItem Class

    [Serializable]
    public class CheckBoxControlItem : Week
    {
        private bool _controlChecked = false;

        public CheckBoxControlItem(string controlName, bool controlChecked, bool controlEnabled)
            : base(controlName, controlEnabled)
        {
            _controlChecked = controlChecked;
        }

        public bool ControlChecked
        {
            get
            {
                return _controlChecked;
            }
            set
            {
                _controlChecked = value;
            }
        }
    }

    #endregion CheckBoxControlItem Class

    #region DateTimePickerControlItem Class

    [Serializable]
    public class DateTimePickerControlItem : Week
    {
        private DateTime _controlDate;

        public DateTimePickerControlItem(string controlName, DateTime controlDate, bool controlEnabled)
            : base(controlName, controlEnabled)
        {
            _controlDate = controlDate;
        }

        public DateTime ControlDate
        {
            get
            {
                return _controlDate;
            }
            set
            {
                _controlDate = value;
            }
        }
    }

    #endregion DateTimePickerControlItem Class

    #region MaskedTextBoxControlItem Class

    [Serializable]
    public class MaskedTextBoxControlItem : Week
    {
        private string _controlText = string.Empty;

        public MaskedTextBoxControlItem(string controlName, string controlText, bool controlEnabled)
            : base(controlName, controlEnabled)
        {
            _controlText = controlText;
        }

        public string ControlText
        {
            get
            {
                return _controlText;
            }
            set
            {
                _controlText = value;
            }
        }
    }

    #endregion MaskedTextBoxControlItem Class
}

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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions