dont show property when many object selected C# property grid

流过昼夜 提交于 2019-12-11 13:26:55

问题


I know how to prevent a property from being shown in the property grid by using this attribute [Browsable(false)]

but I want to prevent this property from being browsed only when there are more than 1 object selected in the property grid.

I mean that when only one object is selected in the property grid this property will be shown but when 2 or more objects are selected this property won't be browsable!


回答1:


Note: I haven't done it myself, but according to the documentation...

Have you tried BrowsableAttributes, documented here? In your selection code you could probably change the propertyGrid.BrowsableAttributes to reflect if it's a "solo" selection or "multiple" selection, and by tagging the variables accordingly, you should be able to have the display you're looking for.

This thread can probably help you!



来源:https://stackoverflow.com/questions/13673166/dont-show-property-when-many-object-selected-c-sharp-property-grid

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