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]; MPSReportFieldBorders so = new MPSReportFieldBorders(); 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 MPRReportFieldBorders"); } } 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(MPSReportFieldBorders)) { MPSReportFieldBorders so = (MPSReportFieldBorders)value; return(so.Bottom + ", " + so.Left + ", " + so.Right + ", " + so.Top); } return(base.ConvertTo(context, culture, value, destinationType)); }