Export (0) Print
Expand All

EditorAttribute Class

Specifies the editor to use to change a property. This class cannot be inherited.

Namespace: System.ComponentModel
Assembly: System (in system.dll)

[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple=true, Inherited=true)] 
public sealed class EditorAttribute : Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All, AllowMultiple=true, Inherited=true) */ 
public final class EditorAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.All, AllowMultiple=true, Inherited=true) 
public final class EditorAttribute extends Attribute
Not applicable.

When editing the property, a visual designer should create a new instance of the specified editor through a dialog box or drop-down window.

Use the EditorBaseTypeName property to find this editor's base type. The only available base type is UITypeEditor.

Use the EditorTypeName property to get the name of the type of editor associated with this attribute.

For general information on using attributes. see Attributes Overview and Extending Metadata Using Attributes. For more information on design-time attributes, see Attributes and Design-Time Support.

The following code example creates the MyImage class. The class is marked with an EditorAttribute that specifies the ImageEditor as its editor.

[Editor("System.Windows.Forms.ImageEditorIndex, System.Design", 
    typeof(UITypeEditor))]

public class MyImage
{
    // Insert code here.
 }

/** @attribute Editor("System.Windows.Forms.ImageEditorIndex, " 
     + "System.Design", UITypeEditor.class)
 */
public static class MyImage
{
    // Insert code here.
} //MyImage

The following code example creates an instance of the MyImage class, gets the attributes for the class, and then prints the name of the editor used by myNewImage.

public static int Main() {
    // Creates a new component.
    MyImage myNewImage = new MyImage();
 
    // Gets the attributes for the component.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewImage);
 
    /* Prints the name of the editor by retrieving the EditorAttribute 
     * from the AttributeCollection. */
    
    EditorAttribute myAttribute = (EditorAttribute)attributes[typeof(EditorAttribute)];
    Console.WriteLine("The editor for this class is: " + myAttribute.EditorTypeName);
 
    return 0;
 }

public static void main(String[] args)
{
    // Creates a new component.        
    MyImage myNewImage = new MyImage();

    // Gets the attributes for the component.
    AttributeCollection attributes = 
        TypeDescriptor.GetAttributes(myNewImage);

    /* Prints the name of the editor by retrieving the EditorAttribute 
       from the AttributeCollection. 
     */
    EditorAttribute myAttribute = (EditorAttribute)(
        attributes.get_Item(EditorAttribute.class.ToType()));

    Console.WriteLine("The editor for this class is: " 
        + myAttribute.get_EditorTypeName());
} //main

System.Object
   System.Attribute
    System.ComponentModel.EditorAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft