Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Windows Forms » Downloads
 
Add your own
alternative version

Unleash PropertyGrid with Dynamic Properties and Globalization

, 29 Jan 2004 CPOL
The article presents a way to enhance the use of the PropertyGid control with dynamic properties and globalization
using System;
using System.ComponentModel;
using System.Globalization;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Collections;
using CustomControls.ApplicationBlocks;
using CustomControls.Editors;

namespace DynamicProperties
{
	/// <summary>
	/// Summary description for Company.
	/// </summary>
	public class Company:DynamicTypeDescriptor, IComponent
	{
		public event EventHandler Disposed;  //Implement IComponent.Disposed
		private ISite _curISBNSite;
		private  Employee_Collection _Employees= new Employee_Collection();
		private string _CompanyName="Master";
		private string _Address="Calea Bucuresti no 27";


		[Category("Employees")]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
		[Editor(typeof(Employees_CollectionEditor),typeof(System.Drawing.Design.UITypeEditor))]
		public Employee_Collection Employees
		{
			get{return _Employees;}
		}

		[Category("CompanyInfo")]
		public string CompanyName
		{
			get{return _CompanyName;}
			set
			{
				if(value!=_CompanyName)
				{
					_CompanyName= value;
				}
			}
		}

		[Category("CompanyInfo")]
		public string Address
		{
			get{return _Address;}
			set
			{
				if(value!=_Address)
				{
					_Address= value;
				}
			}
		}

		public virtual void Dispose() //Implement IComponent.Dispose()
		{    
			//There is nothing to clean.
			if(Disposed != null)
			{
				Disposed(this,EventArgs.Empty);
			}
		}

		[Browsable(false)]
		public virtual ISite Site //implements IComponent.Site
		{
			get
			{
				return _curISBNSite;
			}
			set
			{
				_curISBNSite = value;
			}
		}

		public Company()
		{
			//
			// TODO: Add constructor logic here
			//
		}
	
		public override void EndInit()
		{
			base.EndInit();
			foreach(Employee emp in Employees )
			{
				emp.EndInit();
			}
		}

		#region "Localization"

		public override string GetLocalizedName(string Name)
		{			
			string name=CustomControls.Globalization.Dictionary.Translate(Name);
			if(name!=null ){return name;}
			return base.GetLocalizedName (Name);
		}

		public override string GetLocalizedDescription(string Description)
		{
			string descr=CustomControls.Globalization.Dictionary.Translate(Description + "_Descr");
			if(descr!=null ){return descr;}
			return base.GetLocalizedName (Description);
		}

        
		#endregion

	}
}

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)

Share

About the Author

Daniel Zaharia
Web Developer
Romania Romania
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 30 Jan 2004
Article Copyright 2004 by Daniel Zaharia
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid