Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / C#

Creating Custom Controls-Providing Design Time Support 2

Rate me:
Please Sign up or sign in to vote.
3.80/5 (14 votes)
2 Mar 20053 min read 74.6K   1.2K   65  
This article explains how we can use Designers for providing Design time support.
using System;
using System.ComponentModel;

namespace Phone_Number_Control
{
	/// <summary>
	/// Summary description for PhoneNumber.
	/// </summary>
	/// 
	[TypeConverter(typeof(PhoneTypeConverter))]
	public class PhoneNumber
	{

		#region User Defined Variables
		private string name;
		/// <summary>
		/// This variable is used to maintain the name value.
		/// </summary>
		public string Name
		{
			get
			{
				return this.name;
			}
			set
			{
				if(null != value)
				{
					this.name = value;
					PropertyChanged("name");
				}
			}

		}

		private string countrycode;
		/// <summary>
		/// This variable is used to maintain the countrycode value.
		/// </summary>
		public string CountryCode
		{
			get
			{
				return this.countrycode;
			}
			set
			{
				if(null != value)
				{
					this.countrycode = value;
					PropertyChanged("countrycode");
				}
			}
		}
		private string areacode;
		/// <summary>
		/// This variable is used to maintain the areacode value.
		/// </summary>
		public string AreaCode
		{
			get
			{
				return this.areacode;
			}
			set
			{
				if(null != value)
				{
					this.areacode = value;
					PropertyChanged("areacode");
				}
			}
		}
		private string phonenumber;
		/// <summary>
		/// This variable is used to maintain the phonenumber value.
		/// 
		/// </summary>
		public string PhoneNum
		{
			get
			{
				return this.phonenumber;
			}
			set
			{
				if(null != value)
				{
					this.phonenumber = value;
					PropertyChanged("phonenumber");
				}
			}
		}
		#endregion

		#region Events
		public event PropertyChangedEventHandler PropertyChanged; 
		#endregion
		public PhoneNumber()
		{
			//
			// TODO: Add constructor logic here
			//
		}

		public override string ToString()
		{
			return "Address";
		}


	}
	/// <summary>
	/// Deelegate delc
	/// </summary>
	public delegate void PropertyChangedEventHandler(string propertyname);
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
Working on .NET for last 6 years. Currently working for TCS.

Comments and Discussions