我有一个自定义控件,它有一个Collection<System.Drawing.Point>
类型的属性。当我使用CollectionEditor
编辑此属性时,CollectionEditor
窗口为"X"
和"Y"
属性显示"Object does not match target type."
。但如果我改用System.Drawing.PointF
,就不会失败。
有没有人能解释一下为什么会出现这种差异?
发布于 2017-06-23 22:54:56
我的解决方案是,在使用集合编辑器编辑列表(点)之前,使用TypeDescriptor.AddAttributes(GetType(Drawing.Point), New TypeConverterAttribute())
将点的类型转换器设置为空,然后使用TypeDescriptor.AddAttributes(GetType(Drawing.Point), New TypeConverterAttribute(GetType(PointConverter)))
将类型转换器设置为默认值。
https://stackoverflow.com/questions/2597737
复制相似问题