c# - TypeConverter in propertygrid only converts from string, not to -
When the property grid is reached, only the conversion mechanism (often called) is called "Foo!" Returns the property string in the grid when I click to edit I get an exception Type.oo. Object type can not be changed to type.
(Not properly translated,) What is a clue from the convert format, why not? And the error indicates that it is trying to convert to a string, not from.
I think that when I want to edit this object, it will have to be converted from foo to string, and when the editing ends. Public class FooTypeConverter: StringConverter {public override object ConvertFrom (ITypeDescriptorContext Reference, CultureInfo Culture, Object Value) {New Foo (string) value); } Convert the public override object (Type the ITE DiskText Contact Reference, CultureInfo Culture, Object Value, Type Type) {Return "Foo!"; } Public override bool CanConvertFrom (ITypeDescriptorContext reference, type source type) {back true; } Public Override Bull CanConvertTo (ITypeDescriptorContext Reference, Type Destination Type) {Back True; }}
Accessing the property:
Foo _fu = new fu (); [Editor (Type Component Modell.Design.Multilline String Editor), Typef (UITEpe Editors) [Typcounter (Typef (Footypeconter))] Public Fu Foo {get {return _foo; } Set {_foo = value; }}
update again; Here is a FooEditor
that should work as a shim:
Comments
Post a Comment