Very Advanced PropertyGrid control use

  • Thread starter Thread starter ANDRES BECERRA
  • Start date Start date
A

ANDRES BECERRA

Herfried K. Wagner was kind enough to point me to the PropertyGrid control
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformspropertygridclasstopic.asp

I have found a few samples of how to use the PropertyGrid control and have gained a decent understanding of it. But of course, as it usually the case, my needs go far beyond the simple examples shown in online samples. All the online samples show how to take a class with already defined properties and to add metadata attributes. My case is very different.

The basic structure for my classes are:

Class GenericToolObject
Readonly Property IsContainer
Readonly Property Enabled
Readonly Property ShowInToolBox
...few others...
Readonly Property Properties() as ToolObjectProperties

Class ToolObjectProperties
(basically just a collection class of ToolObjectPropertyInfo objects)

Class ToolObjectPropertyInfo
Readonly Property Index
Readonly Property Name
Read/Write Property Value ****
Readonly Property Type (as an enumeration type)
...few others...

Instances of GenericToolObjects and its property definitons are loaded at run-time from XSD files. When an object is edited, the property editor will basically need to display the collection of ToolObjectProperties for the GenericToolObject in the PropertyGrid control, showing the ToolObjectPropertyValue.DisplayName on the left, and the ToolObjectPropertyInfo.Value on the right.

I don't see how adding metadata attributes to my classes will do any good, because the information for property category, descriptions, etc comes from the XSD files which are not loaded until runtime.

Can a PropertyGrid control be controlled to the level I need it such that I can tweak it at run-time to render the property categories, descriptions, etc at run-time without metadata attributes? For an initial prototype I basically created my own property editor which renders labels, textboxes, combobox, checkboxes, datagrids etc to represent the properties for a GenericToolObject instance. The VS.Net PropertyGrid control though is so much nicer and more professional looking. I could indeed update my own property editor to render better and to support property groups and the like, but I am wondering if it would be easier to just use the PropertyGrid control for this purpose.

Any help would be greatly appreciated and of course I will share the solution to this if there is one. I get the feeling that I'm the first to delve into this territory and use of the PropertyGrid control.

Thanks,
Andres

**************************************
Andrés Becerra
Pennsylvania, USA
Email not posted due to email stealing A**H***S that poll newsgroups.
**************************************
 
Jay,

You are a king among men sir. You did indeed point me in the right
direction. After some research into the ICustomTypeDescriptor interface, I
came across this article which gave me a working example to learn from.

http://www.codeproject.com/cs/miscctrl/bending_property.asp?df=100&tid=40951
1&forumid=13899&select=409511#xx409511xx

Thanks again!!

--
**************************************
Andrés Becerra
Pennsylvania, USA
Email not posted due to email stealing A**H***S that poll newsgroups.
**************************************
 
Back
Top