EditorAttribute Classe
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Especifica o editor a usar para alterar uma propriedade. Esta classe não pode ser herdada.
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
- Herança
- Atributos
Exemplos
O seguinte exemplo de código cria a MyImage classe. A classe está marcada com um EditorAttribute que especifica o ImageEditor como seu 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
O exemplo de código seguinte cria uma instância da MyImage classe, obtém os atributos da classe e depois imprime o nome do editor usado por 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();
// 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
Observações
Ao editar a propriedade, um designer visual deve criar uma nova instância do editor especificado através de uma caixa de diálogo ou janela suspensa.
Use a EditorBaseTypeName propriedade para encontrar o tipo base deste editor. O único tipo de base disponível é UITypeEditor.
Use a EditorTypeName propriedade para obter o nome do tipo de editor associado a este atributo.
Para informações gerais sobre o uso de atributos. ver Atributos. Para mais informações sobre atributos de tempo de design, consulte Atributos e Suporte Design-Time.
Construtores
| Name | Description |
|---|---|
| EditorAttribute() |
Inicializa uma nova instância da EditorAttribute classe com o editor padrão, que não é editor. |
| EditorAttribute(String, String) |
Inicializa uma nova instância da EditorAttribute classe com o nome do tipo e o nome do tipo base do editor. |
| EditorAttribute(String, Type) |
Inicializa uma nova instância da EditorAttribute classe com o nome do tipo e o tipo base. |
| EditorAttribute(Type, Type) |
Inicializa uma nova instância da EditorAttribute classe com o tipo e o tipo base. |
Propriedades
| Name | Description |
|---|---|
| EditorBaseTypeName |
Recebe o nome da classe base ou interface que serve como chave de pesquisa para este editor. |
| EditorTypeName |
Recebe o nome da classe editor no AssemblyQualifiedName formato. |
| TypeId |
Recebe um ID único para este tipo de atributo. |
Métodos
| Name | Description |
|---|---|
| Equals(Object) |
Devolve se o valor do objeto dado é igual à corrente EditorAttribute. |
| GetHashCode() |
Devolve o código de hash para esta instância. |
| GetType() |
Obtém o Type da instância atual. (Herdado de Object) |
| IsDefaultAttribute() |
Quando sobrescrito numa classe derivada, indica se o valor desta instância é o valor padrão para a classe derivada. (Herdado de Attribute) |
| Match(Object) |
Quando sobrescrito numa classe derivada, devolve um valor que indica se esta instância é igual a um objeto especificado. (Herdado de Attribute) |
| MemberwiseClone() |
Cria uma cópia superficial do atual Object. (Herdado de Object) |
| ToString() |
Devolve uma cadeia que representa o objeto atual. (Herdado de Object) |
Implementações de Interface Explícita
| Name | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de despacho. (Herdado de Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera a informação de tipo de um objeto, que pode ser usada para obter a informação de tipo para uma interface. (Herdado de Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Recupera o número de interfaces de informações de tipo que um objeto fornece (0 ou 1). (Herdado de Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Proporciona acesso a propriedades e métodos expostos por um objeto. (Herdado de Attribute) |