Microsoft updates Forms PropertyGrid to support dark theme in VS2012

The System.Windows.Forms.PropertyGrid is a superb control, IMHO the best and most versatile control I've ever seen. It's over 10 years old and still rocks. The PropertyGrid is used extensively in Visual Studio for as long as I can remember and rightfully so. I enjoy working with it on a daily basis. With Visual Studio 2012, Microsoft introduces the great looking dark theme and guess what, they finally updated the PropertyGrid in order to cope with the new color requirements. The property grid is old and does have some issues as can be seen here, here and here. Some of these issues are now addressed in the new PropertyGrid.

Microsoft decided to fix some PropertyGrid limitations by adding the following new properties (almost all color related);

  • CanShowVisualStyleGlyphs
  • CategorySplitterColor
  • CommandsBorderColor
  • DisabledItemForeColor
  • HelpBorderColor
  • SelectedItemWithFocusBackColor
  • SelectedItemWithFocusForeColor
  • ViewBorderColor

This is awesome news for all devs using the PropertyGrid in their apps (as I do with Silverlight Spy and XAML Spy). The new properties are available when you build .NET 4.5 desktop apps in Visual Studio 2012. But even if you are still bound to .NET 4.0 and Visual Studio 2010 you can use the new properties.

I've been doing some research and here's what I found; the .NET Framework v4 assemblies referenced in your project are located in [ProgramFiles]ReferenceAssemblies. The actual assemblies loaded at runtime originate from the GAC folder in [Windows]Microsoft.NETassembly. And here's the crux, the ReferenceAssemblies differ from the GAC assemblies. The System.Windows.Forms assembly in the GAC contains the new PropertyGrid, where the ReferenceAssembly does not. So the new property grid is available at runtime to .NET 4 apps. This is true only when the .NET 4.5 framework has been installed (remember, NET 4.5 does an in-place upgrade of .NET 4)

So how do you use the new PropertyGrid properties at runtime? Well, assign the propertygrid to a dynamic variable and get/set the properties in a late-bound fashion.

This won't compile;

var grid = new PropertyGrid();
grid.SelectedItemWithFocusBackColor = myForeColor;

But this works fine (no intellisense though)

dynamic grid = new PropertyGrid();
grid.SelectedItemWithFocusBackColor = myForeColor;

So in short; the PropertyGrid has been updated in .NET 4.5, most likely because Microsoft needed it for VS2012. The good news is that the updated property grid can also be used in .NET 4.0 apps.


Latest News

RSS feed

Subscribe to the RSS feed and receive the latest news from First Floor Software in your favorite RSS reader.