Specifies the editor to use to change a property. This class cannot be inherited.
<AttributeUsageAttribute(AttributeTargets.All, AllowMultiple := True, Inherited := True)> _ Public NotInheritable Class EditorAttribute _ Inherits Attribute
Dim instance As EditorAttribute
[AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true, Inherited = true)] public sealed class EditorAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::All, AllowMultiple = true, Inherited = true)] public ref class EditorAttribute sealed : public Attribute
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.
<Editor("System.Windows.Forms.ImageEditorIndex, System.Design", _ GetType(UITypeEditor))> _ Public Class MyImage ' Insert code here. End Class 'MyImage
[Editor("System.Windows.Forms.ImageEditorIndex, System.Design", typeof(UITypeEditor))] public class MyImage { // Insert code here. }
[Editor("System.Windows.Forms.ImageEditorIndex, System.Design", UITypeEditor::typeid)] public ref class MyImage{ // Insert code here. };
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 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
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; }
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; }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98