本帖最后由 maomao198907 于 2011-10-02 10:10:23 编辑

解决方案 »

  1.   

    using System;
    using System.ComponentModel;
    using System.Globalization;
    using System.Drawing;public class PointConverter : TypeConverter {
       // Overrides the CanConvertFrom method of TypeConverter.
       // The ITypeDescriptorContext interface provides the context for the
       // conversion. Typically, this interface is used at design time to 
       // provide information about the design-time container.
       public override bool CanConvertFrom(ITypeDescriptorContext context, 
          Type sourceType) {
          
          if (sourceType == typeof(string)) {
             return true;
          }
          return base.CanConvertFrom(context, sourceType);
       }
       // Overrides the ConvertFrom method of TypeConverter.
       public override object ConvertFrom(ITypeDescriptorContext context, 
          CultureInfo culture, object value) {
          if (value is string) {
             string[] v = ((string)value).Split(new char[] {','});
             return new Point(int.Parse(v[0]), int.Parse(v[1]));
          }
          return base.ConvertFrom(context, culture, value);
       }
       // Overrides the ConvertTo method of TypeConverter.
       public override object ConvertTo(ITypeDescriptorContext context, 
          CultureInfo culture, object value, Type destinationType) {  
          if (destinationType == typeof(string)) {
             return ((Point)value).X + "," + ((Point)value).Y;
          }
          return base.ConvertTo(context, culture, value, destinationType);
       }
    }
      

  2.   

    使用这个类型转换器,问题还是没解决哦,我的类型是Point的集合,不是一个点
      

  3.   

    http://topic.csdn.net/u/20111002/12/bcc5a9a4-dc3d-46cb-9e97-165006c4f7e1.html
      

  4.   

    集合应该是用类似如下 collection editor 去编辑
    // ContactCollectionEditor.cs
    using System;
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Reflection;namespace Samples.AspNet.CS.Controls
    {
        public class ContactCollectionEditor : CollectionEditor
        {
            public ContactCollectionEditor(Type type)
                : base(type)
            {
            }        protected override bool CanSelectMultipleInstances()
            {
                return false;
            }        protected override Type CreateCollectionItemType()
            {
                return typeof(Contact);
            }
        }
    }