EditorAttribute Klasa

Definicja

Określa edytor do zmiany właściwości. Klasa ta nie może być dziedziczona.

public ref class EditorAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true, Inherited=true)]
public sealed class EditorAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true, Inherited=true)>]
type EditorAttribute = class
    inherit Attribute
Public NotInheritable Class EditorAttribute
Inherits Attribute
Dziedziczenie
EditorAttribute
Atrybuty

Przykłady

Poniższy przykład kodu tworzy klasę MyImage . Klasa jest oznaczona za pomocą elementu EditorAttribute , który określa ImageEditor jako jego edytor.

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

public class MyImage
{
    // Insert code here.
 }
<Editor("System.Windows.Forms.ImageEditorIndex, System.Design", _
    GetType(UITypeEditor))> _
Public Class MyImage
    ' Insert code here.
End Class

Poniższy przykład kodu tworzy wystąpienie MyImage klasy, pobiera atrybuty klasy, a następnie wyświetla nazwę edytora używanego przez myNewImageprogram .

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

Uwagi

Podczas edytowania właściwości projektant wizualny powinien utworzyć nowe wystąpienie określonego edytora za pomocą okna dialogowego lub okna rozwijanego.

Użyj właściwości , EditorBaseTypeName aby znaleźć typ podstawowy tego edytora. Jedynym dostępnym typem podstawowym jest UITypeEditor.

EditorTypeName Użyj właściwości , aby uzyskać nazwę typu edytora skojarzonego z tym atrybutem.

Aby uzyskać ogólne informacje na temat używania atrybutów. zobacz Atrybuty. Aby uzyskać więcej informacji na temat atrybutów czasu projektowania, zobacz Atrybuty i obsługa Design-Time.

Konstruktory

EditorAttribute()

Inicjuje EditorAttribute nowe wystąpienie klasy przy użyciu edytora domyślnego, który nie jest edytorem.

EditorAttribute(String, String)

Inicjuje EditorAttribute nowe wystąpienie klasy z nazwą typu i nazwą podstawowego typu edytora.

EditorAttribute(String, Type)

Inicjuje EditorAttribute nowe wystąpienie klasy z nazwą typu i typem podstawowym.

EditorAttribute(Type, Type)

Inicjuje EditorAttribute nowe wystąpienie klasy z typem i typem podstawowym.

Właściwości

EditorBaseTypeName

Pobiera nazwę klasy bazowej lub interfejsu służącego jako klucz wyszukiwania dla tego edytora.

EditorTypeName

Pobiera nazwę klasy edytora w AssemblyQualifiedName formacie .

TypeId

Pobiera unikatowy identyfikator dla tego typu atrybutu.

Metody

Equals(Object)

Zwraca, czy wartość danego obiektu jest równa bieżącej EditorAttributewartości .

GetHashCode()

Zwraca wartość skrótu dla tego wystąpienia.

GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
IsDefaultAttribute()

Podczas zastępowania w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną dla klasy pochodnej.

(Odziedziczone po Attribute)
Match(Object)

Po przesłonięciu w klasie pochodnej zwraca wartość wskazującą, czy to wystąpienie jest równe określonemu obiektowi.

(Odziedziczone po Attribute)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Jawne implementacje interfejsu

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Zestaw nazw jest mapowany na odpowiedni zestaw identyfikatorów wysyłania.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Pobiera informacje o typie dla obiektu, który może służyć do pobierania informacji o typie dla interfejsu.

(Odziedziczone po Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Pobiera informację o liczbie typów interfejsów, jakie zawiera obiekt (0 lub 1).

(Odziedziczone po Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Umożliwia dostęp do właściwości i metod udostępnianych przez obiekt.

(Odziedziczone po Attribute)

Dotyczy