public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string) && value is MinMaxValue) { MinMaxValue tr = (MinMaxValue)value; return(tr.Min.ToString() + "," + tr.Max.ToString()); } return(base.ConvertTo(context, culture, value, destinationType)); }
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value is string) { try { string s = (string)value; string[] strs = s.Split(new char[] { ',' }); MinMaxValue tr = new MinMaxValue(); tr.Min = double.Parse(strs[0]); tr.Max = double.Parse(strs[1]); return(tr); } catch { throw new Exception("Type can't be converted."); } } return(base.ConvertFrom(context, culture, value)); }