In C#, if I have a property of type object, and I know the Type of the object, how can I display the default TypeConverter for the property?
Here is some code:
private Type _valueType { get; set; }
public Type ValueType
{
get
{
return _valueType;
}
set
{
_valueType = value;
}
}
private object _value { get; set; }
public object Value
{
get
{
return _value;
}
set
{
_value = value;
}
}
In the above code, if the ValueType property is a bool, how can I display the default TypeConverter for a bool on the Value property?
This is for a PropertyGrid object's SelectedObject.
I have figured out the code needed.
Here it is:
public TypeConverter GetValueTypeConverter()
{
TypeConverter typeConverter = TypeDescriptor.GetConverter(_valueType);
return typeConverter;
}