
This interface allows a class to provide customized type information about itself. If you take a look at the project settings dialog in Visual Studio.NET, you'll notice that the grid contains properties with nicer-looking names like "Use of MFC," which opens a drop-down list that contains values such as "Use MFC in a Shared DLL." Clearly, there is more going on here than a simple property with an enumerated type. If the grid is being used as part of an interface for end-users, however, they should be presented with something a little less obtuse than "UniqueCustID." Custom Type Descriptors This makes sense for a component like a form designer, where the developer needs to be able to quickly and easily make the connection between a property in the grid and the same property in code.

The standard behavior is to display the actual name of the property from the code. Lastly, creating a surrogate class doesn't lend itself well to "beautifying" the contents of the grid.
Vb.net color property colorconverter propertygrid code#
Even if you wrote an automated tool to generate the code for you, there is still the issue of code bloat in your executable. To create a class to wrap this database, you would have to hand-code the get and set calls for each of the hundred properties. Imagine you have a database of a hundred properties that are stored as key-value pairs. You wouldn't be able to easily write a surrogate class that you could reuse across multiple pieces of data unless they all happened to share the same properties.ĭepending on the design of your system and the organization of your data, it may not be convenient to write a surrogate class. Each surrogate has to be specific to your data, because the runtime merely uses reflection to ask the class what its properties are. Many times, however, it may not be desirable to create such a class. To use the grid, you must write a "surrogate class" that exposes properties that you want to show in the grid, instantiate an object of this class, and then select it into the grid. The problem with this is that it's not very flexible out of the box. It then queries the objects for all their properties, organizes them into groups based on their CategoryAttribute, and uses various UITypeEditor and TypeConverter classes to allow the user to edit the properties as strings. By using the SelectedObject or SelectedObjects property, you can select one or more objects into the control.

Below, I present a set of classes that increase the usability of the property grid. Upon using it, however, I realized that while the control is very flexible and powerful, it takes quite a bit of work to customize. NET Framework, I was impressed that Microsoft finally provided one of their coveted custom controls for public use-in this case, the Visual Basic-like property grid,.
