问题
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