EditorAttribute Classe
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Specifica l'editor da usare per modificare una proprietà. La classe non può essere ereditata.
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
- Ereditarietà
- Attributi
Nell'esempio di codice seguente viene creata la MyImage
classe . La classe è contrassegnata con un EditorAttribute oggetto che specifica come ImageEditor editor.
[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
L'esempio di codice seguente crea un'istanza della classe, ottiene gli attributi per la classe e quindi stampa il nome dell'editor MyImage
usato da 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
Quando si modifica la proprietà, una finestra di progettazione visiva deve creare una nuova istanza dell'editor specificato tramite una finestra di dialogo o una finestra a discesa.
Utilizzare la proprietà per trovare il EditorBaseTypeName tipo di base dell'editor. L'unico tipo di base disponibile è UITypeEditor.
Utilizzare la EditorTypeName proprietà per ottenere il nome del tipo di editor associato a questo attributo.
Per informazioni generali sull'uso degli attributi. vedere Attributi. Per altre informazioni sugli attributi in fase di progettazione, vedere Attributi e Design-Time Supporto.
Editor |
Consente di inizializzare una nuova istanza della classe EditorAttribute con l'editor predefinito, ovvero nessun editor. |
Editor |
Consente di inizializzare una nuova istanza della classe EditorAttribute con il nome del tipo e il nome del tipo base dell'editor. |
Editor |
Consente di inizializzare una nuova istanza della classe EditorAttribute con il nome del tipo e il tipo base. |
Editor |
Consente di inizializzare una nuova istanza della classe EditorAttributecon il tipo e il tipo base. |
Editor |
Ottiene il nome della classe base o dell'interfaccia utilizzata come chiave di ricerca di questo editor. |
Editor |
Ottiene il nome della classe dell'editor nel formato AssemblyQualifiedName. |
Type |
Ottiene un ID univoco per questo tipo di attributo. |
Equals(Object) |
Specifica se il valore dell'oggetto specificato è uguale all'oggetto EditorAttribute corrente. |
Get |
Restituisce il codice hash per l'istanza. |
Get |
Ottiene l'oggetto Type dell'istanza corrente. (Ereditato da Object) |
Is |
In caso di override in una classe derivata, indica se il valore di questa istanza è il valore predefinito per la classe derivata. (Ereditato da Attribute) |
Match(Object) |
Quando è sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza equivale a un oggetto specificato. (Ereditato da Attribute) |
Memberwise |
Crea una copia superficiale dell'oggetto Object corrente. (Ereditato da Object) |
To |
Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |
_Attribute. |
Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch. (Ereditato da Attribute) |
_Attribute. |
Recupera le informazioni sul tipo relative a un oggetto, che possono essere usate per ottenere informazioni sul tipo relative a un'interfaccia. (Ereditato da Attribute) |
_Attribute. |
Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1). (Ereditato da Attribute) |
_Attribute. |
Fornisce l'accesso a proprietà e metodi esposti da un oggetto. (Ereditato da Attribute) |
Prodotto | Versioni |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Feedback su .NET
.NET è un progetto open source. Seleziona un collegamento per fornire feedback: