PropertyGrid mult. controls select, null exception on property set?

﹥>﹥吖頭↗ 提交于 2020-01-05 03:33:11

问题


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

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