Saturday 15 September 2012

c# - How to set properties of a custom UITypeEditor using Attributes -



c# - How to set properties of a custom UITypeEditor using Attributes -

out of curiosity, imagine have such uitypeeditor:

public class customeditor : system.drawing.design.uitypeeditor { public bool dosomething { get; set; } [...] }

and want utilize edit 1 of properties dosomething set true:

public myclass { [editorattribute(typeof(customeditor), typeof(system.drawing.design.uitypeeditor))] public string myproperty { get; set; } [...] }

how specify value dosomething property of customeditor set when instanciating editor? possible @ or have create many classes inheriting customeditor number of possible configurations?

in implementation of uitypeeditor.editvalue can @ context argument reference descriptor of property beingness edited. @ another attribute in set editor configuration values.

public class customeditor : system.drawing.design.uitypeeditor { public override object editvalue( itypedescriptorcontext context, iserviceprovider provider, object value) { var property = context.propertydescriptor; var config = (myconfigattribute) property.attributes[typeof(myconfigattribute)]; // ... } }

c# .net uitypeeditor

No comments:

Post a Comment