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

本文介绍如何通过重载类型转换器中的方法使ComplexProperty属性的子属性Max和Min变得可编辑。通过实现GetPropertiesSupported和GetProperties方法,可以轻松地让这些属性支持编辑功能。


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

实现这些很简单,只需要在这个属性的类型的类型转换器中重载两个方法即可
 1ExpandedBlockStart.gifContractedBlock.gif        /**//// <summary>
 2InBlock.gif        /// 使用指定的上下文返回该对象是否支持属性 (Property)。
 3ExpandedBlockEnd.gif        /// </summary>

 4None.gif        public override bool GetPropertiesSupported(ITypeDescriptorContext context)
 5ExpandedBlockStart.gifContractedBlock.gif        dot.gif{
 6InBlock.gif            return true;
 7ExpandedBlockEnd.gif        }

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

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

16None.gif

The end.

转载于:https://www.cnblogs.com/luqingfei/archive/2007/03/14/674797.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值