ComponentModel, PropertyGrids and Interfaces in C#
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).
精彩评论