Change DisplayName attribute for a property

南笙酒味 提交于 2019-12-11 08:25:10

问题


I am looking for a way to change the value of the DisplayName attribute of a property at run-time. Is this even possible in Windows Forms?


回答1:


Create your own TypeDescriptionProvider for your class, and assign it at runtime to single object (or entire class) using TypeDescriptor. Also look into GetTypeDescriptor and GetProperties, and finally AttributeArray.

In general creating your own type descriptor is not so hard, but you need to read msdn carefully and do a lot of tries.



来源:https://stackoverflow.com/questions/1061856/change-displayname-attribute-for-a-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!