开发者

ComponentModel, PropertyGrids and Interfaces in C#

开发者 https://www.devze.com 2022-12-09 11:32 出处:网络
I have a bunch of objects that implement different interfaces, some propertie开发者_开发知识库s of this interfaces should be showed and edited through a PropertyGrid, but if I specify something like D

I have a bunch of objects that implement different interfaces, some propertie开发者_开发知识库s of this interfaces should be showed and edited through a PropertyGrid, but if I specify something like DisplayName, Browsable or DescriptionAttribute, they will not be "inherited" by the class that implements the interface... why is this? and is there any solution?


No. Unfortunately, attributes implement themselves on a specific type. The interface is a separate type than the member that implements the interface.

You'll need to specify those attributes on each class. It's more work, but it also is more flexible (since those classes can determine exactly how to show their information, and customize as needed).

0

精彩评论

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

关注公众号