Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Property Grid - Dynamic List ComboBox, Validation, and More

, 25 Sep 2009 CPOL
A PropertyGrid implementation showing how-to use, best practices, validation, and more.
propertygrid-demo.zip
PropertyGrid - Demo
CarApplication.exe
CustomControls.dll
DataModel.dll
Utilites.dll
propertygrid-source.zip
PropertyGrid-Source
CarApplication
Converters
Properties
Settings.settings
View
CustomControls
ComboBox
Data
Properties
Rule
DataModel
CarModel
Cars
Wheels
Falken
Kumho
PersonModel
Properties
Utilites
Properties
propertygrid_-_demo.zip
CarApplication.exe
CustomControls.dll
DataModel.dll
Utilites.dll
propertygrid_-_source.zip
PropertyGrid
CarApplication
Converters
Properties
Settings.settings
View
CarDomainModel
Cars
Properties
Wheels
Falken
Kumho
CustomControls
ComboBox
Data
Properties
Rule
DataModel
CarModel
Cars
Wheels
Falken
Kumho
Properties
PersonModel
PersonDomainModel
Properties
PropertyGrid.suo
Utilites
Properties
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using CustomControls;
using CustomControls.ComboBox;
using CustomControls.Data;
using DataModel.CarModel.Cars;
using DataModel.CarModel.Wheels;

namespace CarApplication.View
{
	public class ViewWheel
	{
		#region Properties

		private Car _car;
		private readonly Wheel _wheel;
		private ViewPerson2 _person;
		private SupplyStore.SupplyParts _supplyPartsEnum;

		#endregion

		#region Constructor

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="wheel"></param>
		public ViewWheel( Wheel wheel )
		{
			this._wheel = wheel;
		}

		#endregion

		#region Properties

		/// <summary>
		/// Get/Set for Person
		/// </summary>
		public ViewPerson2 Person
		{
			get { return ( _person ); }
			set { _person = value; }
		}

		/// <summary>
		/// Get/Set for Car
		/// </summary>
		[DefaultValue( "" )]
		[Editor( typeof( ListGridComboBox ), typeof( UITypeEditor ) )]
		[DataList( "CarApplication", "SupplyStore", "Instance.Cars", false, "OnAddedEventHandler" )]
		[Category( "Automobile" ), Description( "Description of Car" ), DisplayName( "Car Type" )]
		public Car Car
		{
			get { return ( _car ); }
			set { _car = value; }
		}

		/// <summary>
		/// Get for Wheel
		/// </summary>
		[Category( "Automobile" ), Description( "Description of Wheel" ), DisplayName( "Wheel Type" )]
		public Wheel Wheel
		{
			get { return _wheel; }
		}

		/// <summary>
		/// Get for Wheel
		/// </summary>
		[Editor( typeof( EnumGridComboBox ), typeof( UITypeEditor ) )]
		[EnumList( typeof(SupplyStore.SupplyParts))]
		[Category( "Misc" ), Description( "Description of Supply Parts Enumeration " ), DisplayName( "Supply Parts Enumeration" )]
		public SupplyStore.SupplyParts SupplyParts
		{
			get { return _supplyPartsEnum; }
			set { _supplyPartsEnum = value; }
		}


		#endregion

		#region Event Handler

		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="arg"></param>
		private void OnAddedEventHandler( object sender, ObjectCreatedEventArgs arg )
		{
			if ( arg != null )
			{
				MessageBox.Show( "You just created a " + arg.DataValue.GetType().Name,
					"Congratulations", MessageBoxButtons.OK, MessageBoxIcon.Information );
			}
		}

		#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

Dave Elliott
Software Developer (Senior) Webbert Solutions
United States United States
Dave is an independent consultant working in a variety of industries utilizing Microsoft .NET technologies.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150128.1 | Last Updated 25 Sep 2009
Article Copyright 2008 by Dave Elliott
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid