Connecting Tech Pros Worldwide Forums | Help | Site Map

Very Advanced PropertyGrid control use

ANDRES BECERRA
Guest
 
Posts: n/a
#1: Nov 19 '05
Herfried K. Wagner was kind enough to point me to the PropertyGrid control
http://msdn.microsoft.com/library/en...classtopic.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.
**************************************

ANDRES BECERRA
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Very Advanced PropertyGrid control use


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/miscct...=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.
**************************************
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@email.msn.com> wrote in message
news:#nSXIcWRDHA.3132@tk2msftngp13.phx.gbl...[color=blue]
> Andres,
> I do not have a clean example handy.
>
> I believe you need to use the ICustomTypeDescriptor interface. This
> interface allows you to dynamically return a list of properties for the
> object you are displaying in the Property Grid.
>
> I use ICustomTypeDescriptor to return a list of properties for an object
> proxy, which works. For the categories & Descriptions I believe you will
> need to override the ICustomTypeDescriptor.GetAttributes method.
>
> My concern is there are one or two other interfaces you need. I use
> ICustomTypeDescriptor for some custom data binding to the data grid, I[/color]
have[color=blue]
> a proxy object that I just delegate most of the ICustomTypeDescriptor
> methods to the actual object. (Via TypeDescriptor)
>
> I took my project and put together a very quick form that uses the[/color]
property[color=blue]
> grid and it seems to work, however I do not have attributes, so I'm not[/color]
sure[color=blue]
> about that.
>
> Hopefully this enough to get you headed in the right direction! ;-)
>
> Hope this helps
> Jay
>
> "ANDRES BECERRA" <a.becerra@sap.com> wrote in message
> news:beeigb$sst$1@news1.wdf.sap-ag.de...
> Herfried K. Wagner was kind enough to point me to the PropertyGrid control
>[/color]
http://msdn.microsoft.com/library/en...windowsformspr
opertygridclasstopic.asp[color=blue]
>
> 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[/color]
case,[color=blue]
> my needs go far beyond the simple examples shown in online samples. All[/color]
the[color=blue]
> online samples show how to take a class with already defined properties[/color]
and[color=blue]
> 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[/color]
will[color=blue]
> 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[/color]
from[color=blue]
> the XSD files which are not loaded until runtime.
>
> Can a PropertyGrid control be controlled to the level I need it such that[/color]
I[color=blue]
> 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[/color]
PropertyGrid[color=blue]
> 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.
> **************************************
>
>[/color]


Closed Thread