PropertyDescriptor
In the Visual Studio.NET IDE, you may have wondered how the property grid works, especially when the properties show interesting dropdowns, like the colors or a list of dataset fields. It turns out that this all works through the magic of PropertyDescriptors.
I thought it might be nice to re-use this magic in my own forms applications. After all, it has mechanisms for handling captions, field descriptions, multiple styles of entering or shoosing data, etc. Plus, if you do it right, you should be able to re-use the functionality in different editing environments, such as a datagrid.
I’m almost there, but this has been a little bit of a timesink for me. It is complex, and testing can be difficult. Although there is a PropertyGrid control, there is not a control for each item in the property grid. So that had to be coded. Luckily, someone else did the brunt of that work.
My challenge has been in trying to develop a generic control that derives its context from the existing pieces that make up the application. It needs to get captions from one place, and lookup information from another, and type information from another. All of this has to be done in a way that makes it really, really easy for new forms to be developed.
The idea is that screen developers can drop a control onto a form, and then choose from a predefined set of fields. The framework will take care of the correct type of editor for the field, including appropriate lookup lists, or popup dialogs (ala the Font Dialog), and field captions. In this way, we can ensure consistency through all forms. We still have the flexibility of writing code-behind the forms, but we do not have to worry about the small stuff.
In the end, I’m hoping we can ship off screen designs to a separate group, which will not need any coding skills.