更改显示名称属性,属性 [英] Change DisplayName attribute for a property

查看:203
本文介绍了更改显示名称属性,属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一种方法来改变在运行时的属性的显示名称属性的值。在Windows窗体这甚至可能吗?

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?

推荐答案

创建自己的 TypeDescriptionProvider 为您的类,并在运行时单个对象(或整个班级),使用的 TypeDescriptor 。还应考虑<一个href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.typedescriptionprovider.gettypedescriptor.aspx\"相对=nofollow> GetTypeDescriptor 和<一个href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.icustomtypedescriptor.getproperties.aspx\"相对=nofollow>的GetProperties 中,终于<一个href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.memberdescriptor.attributearray.aspx\"相对=nofollow> AttributeArray 。

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.

在一般创建自己的类型描述并不难,但你需要仔细阅读MSDN和做了很多的尝试。

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

这篇关于更改显示名称属性,属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆