EditorAttribute Kelas

Definisi

Menentukan editor yang akan digunakan untuk mengubah properti. Kelas ini tidak dapat diwariskan.

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
Warisan
EditorAttribute
Atribut

Contoh

Contoh kode berikut membuat MyImage kelas . Kelas ditandai dengan EditorAttribute yang menentukan ImageEditor sebagai editornya.

[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

Contoh kode berikut membuat instans MyImage kelas , mendapatkan atribut untuk kelas , lalu mencetak nama editor yang digunakan oleh myNewImage.

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

Keterangan

Saat mengedit properti, desainer visual harus membuat instans baru editor yang ditentukan melalui kotak dialog atau jendela drop-down.

EditorBaseTypeName Gunakan properti untuk menemukan jenis dasar editor ini. Satu-satunya jenis dasar yang tersedia adalah UITypeEditor.

EditorTypeName Gunakan properti untuk mendapatkan nama jenis editor yang terkait dengan atribut ini.

Untuk informasi umum tentang menggunakan atribut. lihat Atribut. Untuk informasi selengkapnya tentang atribut waktu desain, lihat Atribut dan Dukungan Design-Time.

Konstruktor

EditorAttribute()

Menginisialisasi instans EditorAttribute baru kelas dengan editor default, yang bukan editor.

EditorAttribute(String, String)

Menginisialisasi instans EditorAttribute baru kelas dengan nama jenis dan nama jenis dasar editor.

EditorAttribute(String, Type)

Menginisialisasi instans EditorAttribute baru kelas dengan nama jenis dan jenis dasar.

EditorAttribute(Type, Type)

Menginisialisasi instans EditorAttribute baru kelas dengan jenis dan jenis dasar.

Properti

EditorBaseTypeName

Mendapatkan nama kelas dasar atau antarmuka yang berfungsi sebagai kunci pencarian untuk editor ini.

EditorTypeName

Mendapatkan nama kelas editor dalam AssemblyQualifiedName format .

TypeId

Mendapatkan ID unik untuk jenis atribut ini.

Metode

Equals(Object)

Mengembalikan apakah nilai objek yang diberikan sama dengan saat ini EditorAttribute.

GetHashCode()

Mengembalikan kode hash untuk instans ini.

GetType()

Mendapatkan dari instans Type saat ini.

(Diperoleh dari Object)
IsDefaultAttribute()

Ketika ditimpa di kelas turunan, menunjukkan apakah nilai instans ini adalah nilai default untuk kelas turunan.

(Diperoleh dari Attribute)
Match(Object)

Saat ditimpa di kelas turunan, mengembalikan nilai yang menunjukkan apakah instans ini sama dengan objek tertentu.

(Diperoleh dari Attribute)
MemberwiseClone()

Membuat salinan dangkal dari saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Implementasi Antarmuka Eksplisit

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

Memetakan sekumpulan nama ke sekumpulan pengidentifikasi pengiriman yang sesuai.

(Diperoleh dari Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Mengambil informasi jenis untuk objek, yang dapat digunakan untuk mendapatkan informasi jenis untuk antarmuka.

(Diperoleh dari Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Mengambil jumlah antarmuka informasi jenis yang disediakan objek (baik 0 atau 1).

(Diperoleh dari Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Menyediakan akses ke properti dan metode yang diekspos oleh objek.

(Diperoleh dari Attribute)

Berlaku untuk