EditorAttribute Klasa
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Określa edytor do zmiany właściwości. Tej klasy nie można dziedziczyć.
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
- Atrybuty
Przykłady
Poniższy przykład kodu tworzy klasę MyImage . Klasa jest oznaczona znakiem EditorAttribute , który określa ImageEditor jako 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 dla 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();
// 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 wizualizacji 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
| Nazwa | Opis |
|---|---|
| EditorAttribute() |
Inicjuje nowe wystąpienie EditorAttribute klasy przy użyciu edytora domyślnego, który nie jest edytorem. |
| EditorAttribute(String, String) |
Inicjuje EditorAttribute nowe wystąpienie klasy o nazwie typu i nazwie podstawowego typu edytora. |
| EditorAttribute(String, Type) |
Inicjuje EditorAttribute nowe wystąpienie klasy o nazwie typu i typie podstawowym. |
| EditorAttribute(Type, Type) |
Inicjuje EditorAttribute nowe wystąpienie klasy z typem i typem podstawowym. |
Właściwości
| Nazwa | Opis |
|---|---|
| EditorBaseTypeName |
Pobiera nazwę klasy bazowej lub interfejsu służącego jako klucz odnośnika dla tego edytora. |
| EditorTypeName |
Pobiera nazwę klasy edytora w AssemblyQualifiedName formacie . |
| TypeId |
Pobiera unikatowy identyfikator tego typu atrybutu. |
Metody
| Nazwa | Opis |
|---|---|
| Equals(Object) |
Zwraca, czy wartość danego obiektu jest równa bieżącej EditorAttributewartości . |
| GetHashCode() |
Zwraca kod skrótu dla tego wystąpienia. |
| GetType() |
Pobiera Type bieżącego wystąpienia. (Odziedziczone po Object) |
| IsDefaultAttribute() |
Po zastąpieniu w klasie pochodnej wskazuje, czy wartość tego wystąpienia jest wartością domyślną dla klasy pochodnej. (Odziedziczone po Attribute) |
| Match(Object) |
Po zastąpieniu 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 Object. (Odziedziczone po Object) |
| ToString() |
Zwraca ciąg reprezentujący bieżący obiekt. (Odziedziczone po Object) |
Jawne implementacje interfejsu
| Nazwa | Opis |
|---|---|
| _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 obiektu, którego można użyć do uzyskania 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) |
Zapewnia dostęp do właściwości i metod uwidocznionych przez obiekt. (Odziedziczone po Attribute) |