public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo culture, object value) { if (value.GetType() == typeof(string)) { try { string[] s = value.ToString().Split(','); if ((s.GetUpperBound(0) > 2)) { string bottom = s[0]; string left = s[1]; string right = s[2]; string top = s[3]; MPSReportFieldPadding so = new MPSReportFieldPadding(); so.Top = int.Parse(top); so.Bottom = int.Parse(bottom); so.Left = int.Parse(left); so.Right = int.Parse(right); return(so); } } catch { throw new ArgumentException("Can not convert '" + value.ToString() + "' to type MPRReportFieldPadding"); } } return(base.ConvertFrom(context, culture, value)); }
public override object ConvertTo( ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if ((destinationType.GetType() == typeof(System.String) && value.GetType() == typeof(MPSReportFieldPadding))) { MPSReportFieldPadding so = (MPSReportFieldPadding)value; return(so.Bottom + ", " + so.Left + ", " + so.Right + ", " + so.Top); } return(base.ConvertTo(context, culture, value, destinationType)); }