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:

FooEditor: UITypeEditor {MultilineStringEditor ed = new MultilineStringEditor (); Public override object EditValue (ITypeDescriptorContext reference, IServiceProvider provider, object value) {value as Foo foo = Foo; If (foo! = Null) {value = new Foo ((string) ed.EditValue (provider, foo.Value)); } return value; } Public override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext Reference) {return ed.GetEditStyle (); } Public Override Bull iSaidDownDisable {get {return ed.IsDropDownResizable; } [Editor (TypeEoo (FooEditor)] [Type (FooTypeConverter)] [Type (FooTypeConverter)] [] Typef (UITypeEditor)] Square Fu {/ * ... * /}

Comments

Popular posts from this blog

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -