Hi,
I have a property with a custom BooleanConverter to display custom strings instead of "true" and 'false"
Here is the property:
[TypeConverter(typeof(UnitConverter))]
public bool unit
{
get { return m_millimeterUnit; }
set { m_millimeterUnit = value; }
}
And the converter:
[ComVisible(false)]
public class UnitConverter : BooleanConverter
{
public override object ConvertTo(ITypeDescriptorContext x_context, CultureInfo x_culture, object x_value, Type x_destinationType)
{
object l_ret;
if ((typeof(string) == x_destinationType) && (x_value != null))
{
bool l_millimeterUnit = (bool)x_value;
l_ret = l_millimeterUnit ? "mm":"Inches");
}
else
{
l_ret = base.ConvertTo(x_context, x_culture, x_value, x_destinationType);
}
return l_ret;
}
public override bool CanConvertTo(ITypeDescriptorContext x_context, Type x_destinationType)
{
return (typeof(string) == x_destinationType) || base.CanConvertTo(x_context, x_destinationType);
}
public override object ConvertFrom(ITypeDescriptorContext x_context, CultureInfo x_culture, object x_value)
{
object l_ret;
string l_value = x_value as string;
if (l_value != null)
{
l_ret = (l_value != "Inches");
}
else
{
l_ret = base.ConvertFrom(x_context, x_culture, x_value);
}
return l_ret;
}
}
The problem is that the standard propertygrid is working as expected, but not the Actipro's propertygrid which shows a checkbox instead.
How can I customize this checkbox and get a combobox with my 2 strings ("inches" and "mm") ?
Best regards,