Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

PropertyGrid

I had to think a while about the PropertyGrid. It certainly is a useful control when you work within the Visual Studio IDE, but uses outside of that context seem somewhat limited. The PropertyGrid looks just like the lower portion of the properties window, as shown in Figure 6. You associate it with a particular control, using the SelectedObject property.

Figure 6

Figure 6 Use a PropertyGrid to display the properties for any control in the current application.

After playing with this control for a while, it occurred to me that it actually has several very interesting uses:

  • Use it to create an IDE of your own in an application. Your application might support a scripting language such as VBA, so the PropertyGrid can save you considerable time and effort in this context.
  • Use it with applications that manipulate graphics or other object. Creating custom objects lets you display just the properties that the user should change in the PropertyGrid control.
  • Use it as a debugging aid. Instead of playing with a ton of debug statements, you can see the properties during runtime just as you would during design time. Changes you make to the PropertyGrid affect the associated control, so you can easily see how runtime changes will work without a lot of experimentation.
  • Use it for document identification. By creating a special document identification control, you can easily simulate the advanced functionality of the document properties pages found in applications such as Office.

It’s interesting that the PropertyGrid isn’t explored more. You can’t find very many articles on its use on the Internet, and the articles you do find are mundane. This is one of those controls that doesn’t seem obviously useful at first, but as you work with it, you’ll find all kinds of uses for it.

  • + Share This
  • 🔖 Save To Your Account