开发者

Adding a custom attribute to a type created using reflection

I have created a type and with few properties and assigned values to those properties. I need to bind this class with a property grid. I need to add/decorate custom attribute to some of the properties i have created using reflection.

Could some one help me addi开发者_JAVA百科ng a custom attribute using reflection.

[TypeConverter(typeof(DropDownConverter))]
        public string NAME
        {
            get { return m_name; }
            set
            {
                m_name = value;
            }
        }

Finally the property should have a TypeConverter attribute added to it.

Thanks, Kishore Borra.


You need to implement ICustomTypeDescriptor and implement GetProperties to return custom PropertyDescriptors that contain you attributes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜