PropertyGrid and object fields

E

Eric Eggermann

Hello,
I'm using a PropertyGrid on my form in lieu of a big ugly dialog box, or
rather several large dialogs, so the user can manipulate some objects. I've
got a font field that displays with a nice little drop down feature showing
the font properties slightly indented from the other properties. In the .Net
editor, this works for quite a few fields such as Size, and DataBindings.
How can I get one of my own classes, which exists as a field in other
classes to behave the same way in the property grid?

In other words, I've got a read/write field which exposes another object in
the class that I set as the PropertyGrid's SelectedObject, but all I get in
the PropertyGrid is a string showing the type of the field.

Hope I've made myself clear.

Eric Eggermann
 
V

Vijaye Raji

You have to implement a "TypeConverter" for your object. In the type
converter class, you have to override "GetProperties" method and construct a
"PropertyDescriptor" collection and return it. This will make the Property
grid work the way you want it.

(look up on the words in quote in MSDN - there's plenty of documentation to
help u along the way)

VJ
 
E

Eric Eggermann

Vijaye Raji said:
You have to implement a "TypeConverter" for your object. In the type
converter class, you have to override "GetProperties" method and construct a
"PropertyDescriptor" collection and return it. This will make the Property
grid work the way you want it.

(look up on the words in quote in MSDN - there's plenty of documentation to
help u along the way)

Thanks very much Vijaye. Your search terms brought me to the answer. In my
case, I didn't actually have to implement anything. I just needed to set the
following attribute,
[TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]

to the properties exposing my object.

It's easy when you know how, huh.

Eric Eggermann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top