How To: Display objects in a PropertyGrid DropDown list?

S

Steve

I followed the MSDN example that uses a StringConverter to display states
(like Ohio, Florida,) in a PropertyGrid using a DropDown list. This works
fine for strings, but I would like to do this with objects I create on the
fly.

I think I have to create a custom TypeConverter, but I'm not sure how. Any
examples would be helpful.

Thanks,

Steve
 
F

Frank Hileman

Hello Steve,

You need a custom UITypeEditor, that overrides GetEditStyle, and returns
UITypeEditorEditStyle.DropDown. Then you override EditValue, and have that
function create a custom form of your own creation. Be sure to use a
PropertyDescriptor (via TypeDescriptor) to change the final property, so you
get a designer transaction, and the OnComponentChanging/OnComponentChanged
functions are called automatically for your property.

Look for articles by Shawn Burke, especially the one with "RAD" in the
title, for more info on the property grid.

Regards,
Frank Hileman

check out VG.net: www.vgdotnet.com
Animated vector graphics system
Integrated VS.net graphics editor
 
H

Herfried K. Wagner [MVP]

Frank,

* "Frank Hileman said:
You need a custom UITypeEditor, that overrides GetEditStyle, and returns
UITypeEditorEditStyle.DropDown. Then you override EditValue, and have that
function create a custom form of your own creation. Be sure to use a
PropertyDescriptor (via TypeDescriptor) to change the final property, so you
get a designer transaction, and the OnComponentChanging/OnComponentChanged
functions are called automatically for your property.

Look for articles by Shawn Burke, especially the one with "RAD" in the
title, for more info on the property grid.

A very interesting article on the PropertyGrid can be found here:

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/usingpropgrid.asp>
 

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