Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using PropertyGrid with dynamically generated type/class

1 view
Skip to first unread message

Douglas R. Steen

unread,
Dec 6, 2003, 1:12:10 AM12/6/03
to
I'd like to use the propertyGrid for my UI, but I don't
have a precompiled class for the SelectedObject
property. Instead, I'd like to create one on the fly
using Reflection. So far, it works except when it comes
to creating the Description, Category, etc. attributes.
I created a runtime assembly, class, and property and
then added a custom attribute to that property of
DescriptionAttribute type. When I check the property
info for a test precompiled class and my on-the-fly
class, they look exactly the same, but for some readon
the PropertyGrid doesn't see mine. Any ideas?

Thanks in advance,
Douglas R. Steen
Boulder, CO

Bob Powell [MVP]

unread,
Dec 6, 2003, 7:54:46 AM12/6/03
to
When you create your class, do you provide the Browsable attribute for the
properties you want to see? PropertyGrid will only show properties with
Browsable(true). This is added by default for classes compiled in the normal
manner but it might have to be done explicitly in this case.

You might also try implementing ICustomTypeDescriptor for your class and
ensure that property descriptions are returned regardless of their apparent
browsability.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Douglas R. Steen" <d...@pobox.com> wrote in message
news:1b2a01c3bbbf$e24fbcd0$7d02...@phx.gbl...

Douglas R. Steen

unread,
Dec 6, 2003, 10:24:42 PM12/6/03
to
Bob -
Thanks for the BrowsableAttribute suggestion, but the
properties are showing up in the PropertyGrid, I'm just
not seeing the Description or Category. I tried adding
Browsable(true), but no luck. I'll look into
PropertyDescriptors next; I think that's where the
PropertyGrid gets its real info anyway.
Help appreciated,
Douglas R. Steen

>.
>

Vadim Berman

unread,
Dec 7, 2003, 6:49:43 AM12/7/03
to
Douglas,

What do you want to accomplish - a propertyGrid for dynamically assembled
object, or a propertyGrid-like view to display some info? Because if it is
the latter, then we have recently built a control that does just this. We
use it as a "sidecar" for our own datagrid.

--
Vadim Berman
www.Power-Components.NET
-----------------------------------------
Powerful components for powerful applications


"Douglas R. Steen" <d...@pobox.com> wrote in message
news:1b2a01c3bbbf$e24fbcd0$7d02...@phx.gbl...

0 new messages