问题
I have a custom object, ComplexName, that I want to show in the propertygrid (in the VS designer, not at runtime).
It all seems to work correctly (with the ExpandableObjectConverter implemented), when I have just one control selected. I can set any\all of the attributes the way I want them to (expanded or via the typeconverter).
When I select multiple controls though, the issue starts.
At first, When you selected multiple objects with the same property (with the same value), I wanted the text to show (similar to dock, for instance). I fixed that by overriding equals.
The problem:
When I have multiple object selected, and I type in a new value for the object, one of two things will happen:
If all object currently have the same value: the new value is loaded properly. if the values are not equal: a null pointer exception will be thrown.
Keep in mind this is only on the "typeconverter" line. If i multi-select and change any objects in the expanded section, everything is fine.
来源:https://stackoverflow.com/questions/9619769/propertygrid-mult-controls-select-null-exception-on-property-set