TypeConverter for a PropertyGrid

M

moni

PropertyDescriptor Class has a Converter method, which if overriden,
would return a TypeConverter.

I was working on dynamic values for a propertygrid, so for each
property all the methods of the PropertyDescriptor class were
overridden. But for a dropdown list I needed the COnverter method
also, but I dont know how I would do it?

eg.

public override Type PropertyType
{
get { return Type.GetType(item.TypeName); }
}

returns a Type.

public override TypeConverter Converter
{
get
{
return ?
}

}

Please help. Any help will be appreciated.

Thanx
 
M

Marc Gravell

If you want the default converter for the type, then:
TypeDescriptor.GetConverter(PropertyType)...

However! Note that you don't need to override this; the default
implementation will do the above as the default, but will also
correctly support TypeConverterAttribute if specified for the
property. As a general rule, you don't need to provide all the
functionality yourself...

Marc
 

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