Click here to Skip to main content
15,616,191 members
Articles / Programming Languages / C#
Posted 29 Aug 2008


86 bookmarked

A C# 2008 Advanced Customizable PropertyGrid Control

Rate me:
Please Sign up or sign in to vote.
4.58/5 (17 votes)
29 Aug 2008CPOL3 min read
This user control is similar to the standard Microsoft .NET 2.0 PropertyGrid control with several additional features


This property grid control has been developed in Visual Studio C# 2008. This user control is similar to the standard Microsoft .NET 2.0 PropertyGrid control with several additional features:

  • Gets/sets any property item at runtime (e.g. change property’s help text)
  • New property items (Date and Time, Date, Time, File, Directory, ProgressBar, ...)
  • Multi-language support
  • Image Preview
  • Date calendar
  • Numeric interval automatic validation
  • Customizable Boolean type (yes/no, true/false, ..)
  • Customizable engineering unit for numeric values
  • Use .NET standard dialog box, text title, new buttons (show text, apply), ...

This control is fully customizable at runtime. Property items can be added and changed at any time.


The main problem of the Microsoft .NET 2.0 standard Property Grid Control is that it is not easy to control at run-time. Using this control is possible, for example, to change the language at runtime or to change a property that normally is read-only using the standard control.

Using the Code

To run the example project:

  1. Extract all files from ZIP into a folder
  2. Run Visual Studio C #2008 and select the command "File" > "Open project"
  3. Select the file "\Test\Test_mbrPropertyGrid\Test_mbrPropertyGrid.sln"
  4. Select the command "Build" > "Rebuild solution"
  5. Press the [F5] keyboard button to run the program

To build your new test project:

  1. Run Visual Studio C #2008 and create a new project (standard Windows form application)
  2. Add a reference to the .NET DLL "mbrPropertyGrid.dll"
  3. Right-click in toolbox windows and select the command "Choose Items..."
  4. Select the browse button and select the .NET DLL "mbrPropertyGrid.dll"
  5. Drag and drop the new PropertyGrid icon from the toolbox to your project form to add the control to your project
  6. Set the control properties to customize it
  7. Write code to add/manage property items

To logically group the various item objects, at first, add a category item:

mbrPropertyGrid.PropertyItemCategory catItem;
catItem = new mbrPropertyGrid.PropertyItemCategory("Main Category");
PropertyGrid1.CategoryAdd("CatMain", catItem);

To add property items to a category use the .ItemAdd method like the following example :

mbrPropertyGrid.PropertyItemInt32 intItem;
intItem = new mbrPropertyGrid.PropertyItemInt32("Line02 - Age (Int32)", 0);
intItem.SetValidationRange(0, 120, 1);
intItem.SetHelpCaptionText("Age", "Tell me your age (valid range : 0..120)");
PropertyGrid1.ItemAdd("CatMain", "MyAge", intItem);

mbrPropertyGrid.PropertyItemString strItem;
strItem = new mbrPropertyGrid.PropertyItemString
	("Line01 - Name (String)", "Jak", "Jak Smith");
strItem.HelpCaption = "Name";
strItem.HelpText = "Tell me your name...";
PropertyGrid1.ItemAdd("CatMain", "YourName", strItem);

To disable a property item, set the item property .Enabled to false like in the following example:

strItem = new mbrPropertyGrid.PropertyItemString
	("Line03 - Job (String)", "A software developer");
strItem.HelpText = "Tell me about your job";
strItem.Enabled = false;
PropertyGrid1.ItemAdd("CatMain", "K03", strItem);

When you have completed the addition of item objects to force the complete control repaint, run the .RefreshControl(true) method like in the following code:

// Full control repaint

A quick screen shot control preview. Please note that the standard dialog box will be shown in the same language of the operating system.














Points of Interest

To change the language at runtime, simply change the following properties of the property items: Text, HelpCaption, HelpText (and Description for a Directory Item).


  • Version - 28/08/2008: This is the first version. Some points have to be accommodated. For example, there is a known bug on a video refresh of the .Text property. I suggest, at the moment, to disable the Text property view by setting .TextVisible = false;

About Me

My name is Massimiliano Brugnerotto and I'm an Italian C# software developer. I believe that open source software is a useful resource and with this article, I will give my contribution to this site that on many occasions gave me interesting development solutions.


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

Written By
Software Developer (Senior) Palladio Software House s.r.l.
Italy Italy
My main experience as software developer in short

From 2014-today : WPF C# developing of desktop application and WPF controls (NPoco ORM). Web developer using C# ASP.NET MVC5 and Entity Framework
17/03/2008-2014 : WinForm C# 2005-2008 developer and Web developer (HTML, PHP, MySQL), QlikView Business Intelligence Developer
14/03/2001-15/03/2008 : WinForm VisualBasic 6.0, C#2003, C# 2005 developer and finally, in the 2007-8, also web developer (HTML, PHP, MySQL)
01/11/1992-13/03/2001 : MS-DOS Turbo Pascal 7.0 (OOP), Quick Basic 4.5 developer and WinForm Visual Basic 3.0 / 5.0 developer.

Comments and Discussions

SuggestionRTL problem Pin
Member 1151927623-Oct-15 11:10
Member 1151927623-Oct-15 11:10 
BugItem Select - Scroll Not Working Pin
MainOp18-Aug-15 7:41
MainOp18-Aug-15 7:41 
GeneralMy vote of 5 Pin
Maxwolf Goodliffe14-Dec-14 17:43
Maxwolf Goodliffe14-Dec-14 17:43 
QuestionNubom, Russia Pin
nubom7-Nov-14 3:25
nubom7-Nov-14 3:25 
QuestionPropertyGrid.SelectedObject ? Pin
krysiu_2417-Sep-13 19:55
krysiu_2417-Sep-13 19:55 
QuestionHierachical Categories Pin
BrasilBrasil21-Feb-13 2:05
BrasilBrasil21-Feb-13 2:05 
QuestionCategoriesClear ?? Pin
IMikeO30-Sep-11 7:54
IMikeO30-Sep-11 7:54 
QuestionAm I missing something? Pin
Brad Yinger21-Aug-09 11:56
Brad Yinger21-Aug-09 11:56 
AnswerRe: Am I missing something? PinPopular
Brad Yinger21-Aug-09 12:10
Brad Yinger21-Aug-09 12:10 
GeneralIterate over added items Pin
Schmullus13-Mar-09 1:35
Schmullus13-Mar-09 1:35 
GeneralRe: Iterate over added items Pin
SlingBlade25-Mar-09 20:43
SlingBlade25-Mar-09 20:43 
GeneralHyperlinks Pin
Mark Storen21-Jan-09 19:34
Mark Storen21-Jan-09 19:34 
GeneralSelectedObject Pin
netJP12L2-Dec-08 7:42
netJP12L2-Dec-08 7:42 
QuestionHow to move with one Main heading by using tab key? Pin
73amit11-Nov-08 20:25
73amit11-Nov-08 20:25 
GeneralFantastic!! Pin
Steve Stamm7-Nov-08 9:29
Steve Stamm7-Nov-08 9:29 
QuestionVery interesting Pin
E! Ray K6-Nov-08 5:51
E! Ray K6-Nov-08 5:51 
I can see you have pour significant time into this. Normally, to get it up quickly in my project with additional functionality, I would just subclass from PropertyGrid, there's many codeproject out there that is doing this. However, this is the first time I've seen PropertyGrid written from scratch. UI looks amazing and your project can make use .NET 3.5 features. So, the potential of making it better is there.

I am wondering why you derive away from the fundamental behavior of PropertyGrid, what I mean by this is whenever propertygrid accepts a object, it will dynamically display propertytabs for every possible property in the object, such as by PropertyGrid.SelectObject = new Address(); Something like that.
It's what propertygrid so great in the first place.

Go with the flow...

GeneralExcellent Pin
netJP12L27-Oct-08 18:30
netJP12L27-Oct-08 18:30 
GeneralValue Changed Event Pin
Member 281764113-Oct-08 14:18
Member 281764113-Oct-08 14:18 
AnswerRe: Value Changed Event Pin
Massimiliano Brugnerotto18-Oct-08 5:11
Massimiliano Brugnerotto18-Oct-08 5:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.