TypeConverter for a UserControl

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am working on a custom DataGridColumnStyle that can host a UserControl. I
have created a public property on this ColumnStyle of type MyUserControlBase.
I would like to be able to set this property in the PropertyGrid by choosing
from a list of UserControls that inherit from MyUserControlBase.

Using a TypeConverter that inherits from TypeList Converter, I have been
able to get the property to show up in the PropertyGrid and I can even get
the drop-down list to show the list of UserControls. But when I select one
of them, I get a designtime error of "Invalid property value - Object type
cannot be converted to target type." I have tried numerous combinations of
overriding CanConvertFrom/ConvertFrom & CanConvertTo/ConvertTo without
success.

Can someone give me a push in the right direction? Thanks.

Tony
 
Are you overriding the 'GetCreateInstanceSupported', 'CreateInstance', and
'ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo
culture, object value, Type destinationType)' methods it your type converter?

If not, it could be that your type converter is not creating the proper
instance type.
 
Back
Top