Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
EditorAttribute Class

Updated: November 2007

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

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

Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.All, AllowMultiple := True, Inherited := True)> _
Public NotInheritable Class EditorAttribute _
    Inherits Attribute
Visual Basic (Usage)
Dim instance As EditorAttribute
C#
[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true, Inherited = true)]
public sealed class EditorAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::All, AllowMultiple = true, Inherited = true)]
public ref class EditorAttribute sealed : public Attribute
J#
/** @attribute AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true, Inherited = true) */
public final class EditorAttribute extends Attribute
JScript
public final class EditorAttribute extends Attribute

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.

Visual Basic
<Editor("System.Windows.Forms.ImageEditorIndex, System.Design", _
    GetType(UITypeEditor))> _
Public Class MyImage
    ' Insert code here.
End Class 'MyImage

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

public class MyImage
{
    // Insert code here.
 }

Visual C++
[Editor("System.Windows.Forms.ImageEditorIndex, System.Design",
UITypeEditor::typeid)]
public ref class MyImage{
   // Insert code here.
};

J#
/** @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.

Visual Basic
Public Shared Sub Main()
    ' Creates a new component.
    Dim myNewImage As New MyImage()

    ' Gets the attributes for the component.
    Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewImage)

    ' Prints the name of the editor by retrieving the EditorAttribute
    ' from the AttributeCollection. 

    Dim myAttribute As EditorAttribute = CType(attributes(GetType(EditorAttribute)), EditorAttribute)
    Console.WriteLine(("The editor for this class is: " & myAttribute.EditorTypeName))

End Sub 'Main

C#
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;
 }

Visual C++
int main()
{
   // Creates a new component.
   MyImage^ myNewImage = gcnew 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 = dynamic_cast<EditorAttribute^>(attributes[ EditorAttribute::typeid ]);
   Console::WriteLine( "The editor for this class is: {0}", myAttribute->EditorTypeName );
   return 0;
}

J#
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 Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker