简体   繁体   中英

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 adding 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 PropertyDescriptor s that contain you attributes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM