开发者

Adding a custom attribute to a type created using reflection

开发者 https://www.devze.com 2023-03-27 06:30 出处:网络
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 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

精彩评论

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