How to show or hide properties dynamically in the PropertyGrid?

南楼画角 提交于 2019-12-10 14:36:11

问题


I am using a PropertyGrid for configuring objects. I need to be able to hide or show some properties depending on the values of other properties. How this can be achieved? I know about Browsable attribute, but it only works at a compile time.


回答1:


Take a look into the ICustomTypeDescriptor Interface.

Further informations on how to use it can be found in this article:

  • Bending the .NET PropertyGrid to Your Will.



回答2:


Check this link Changing Browsable Property Attribute dynamically.A sample method is given. Using Reflection access the Property and set its browsable property to true or false.



来源:https://stackoverflow.com/questions/5831878/how-to-show-or-hide-properties-dynamically-in-the-propertygrid

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