现在的位置: 首页 > 综合 > 正文

Dot Net WinForm 控件开发 (五) 复杂属性的子属性

2013年01月03日 ⁄ 综合 ⁄ 共 698字 ⁄ 字号 评论关闭

看到了吧? ComplexProperty 属性的子属性 Max, Min 也可以被编辑了.

实现这些很简单,只需要在这个属性的类型的类型转换器中重载两个方法即可

 1        /// <summary>
 2        /// 使用指定的上下文返回该对象是否支持属性 (Property)。
 3        /// </summary>

 4        public override bool GetPropertiesSupported(ITypeDescriptorContext context)
 5        {
 6            return true;
 7        }

 8
 9        /// <summary>
10        /// 使用指定的上下文和属性 (Attribute) 返回由 value 参数指定的数组类型的属性 (Property) 的集合。
11        /// </summary>

12        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, System.Attribute[] attributes)
13        {
14            return TypeDescriptor.GetProperties(typeof(SimpleCustomType), attributes);
15        }

16

The end.

抱歉!评论已关闭.