DesignerAttribute 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 a classe usada para implementar serviços em tempo de projeto para um componente.
public ref class DesignerAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)]
public sealed class DesignerAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)>]
type DesignerAttribute = class
inherit Attribute
Public NotInheritable Class DesignerAttribute
Inherits Attribute
- Herança
- Atributos
Exemplos
O exemplo seguinte cria uma classe chamada MyForm.
MyForm tem dois atributos, a DesignerAttribute que especifica esta classe usa o DocumentDesigner, e a DesignerCategoryAttribute que especifica a Form categoria.
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL",
IRootDesigner::typeid),
DesignerCategory("Form")]
ref class MyForm: public ContainerControl{
// Insert code here.
};
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL",
typeof(IRootDesigner)),
DesignerCategory("Form")]
public class MyForm : ContainerControl
{
// Insert code here.
}
<Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL", _
GetType(IRootDesigner)), DesignerCategory("Form")> _
Public Class MyForm
Inherits ContainerControl
' Insert code here.
End Class
O exemplo seguinte cria uma instância de MyForm. Depois obtém os atributos da classe, extrai o DesignerAttribute, e imprime o nome do designer.
int main()
{
// Creates a new form.
MyForm^ myNewForm = gcnew MyForm;
// Gets the attributes for the collection.
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewForm );
/* Prints the name of the designer by retrieving the DesignerAttribute
* from the AttributeCollection. */
DesignerAttribute^ myAttribute = dynamic_cast<DesignerAttribute^>(attributes[ DesignerAttribute::typeid ]);
Console::WriteLine( "The designer for this class is: {0}", myAttribute->DesignerTypeName );
return 0;
}
public static int Main()
{
// Creates a new form.
MyForm myNewForm = new();
// Gets the attributes for the collection.
AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewForm);
/* Prints the name of the designer by retrieving the DesignerAttribute
* from the AttributeCollection. */
DesignerAttribute myAttribute =
(DesignerAttribute)attributes[typeof(DesignerAttribute)];
Console.WriteLine("The designer for this class is: " + myAttribute.DesignerTypeName);
return 0;
}
Public Shared Function Main() As Integer
' Creates a new form.
Dim myNewForm As New MyForm()
' Gets the attributes for the collection.
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewForm)
' Prints the name of the designer by retrieving the DesignerAttribute
' from the AttributeCollection.
Dim myAttribute As DesignerAttribute = _
CType(attributes(GetType(DesignerAttribute)), DesignerAttribute)
Console.WriteLine(("The designer for this class is: " & myAttribute.DesignerTypeName))
Return 0
End Function 'Main
Observações
A classe que utiliza para os serviços de design tem de implementar a IDesigner interface.
Use a DesignerBaseTypeName propriedade para encontrar o tipo base do designer. Use a DesignerTypeName propriedade para obter o nome do tipo de designer associado a este membro.
Para obter mais informações, consulte Atributos.
Construtores
| Name | Description |
|---|---|
| DesignerAttribute(String, String) |
Inicializa uma nova instância da DesignerAttribute classe usando o tipo designer e a classe base para o designer. |
| DesignerAttribute(String, Type) |
Inicializa uma nova instância da DesignerAttribute classe, usando o nome da classe designer e a classe base do designer. |
| DesignerAttribute(String) |
Inicializa uma nova instância da DesignerAttribute classe usando o nome do tipo que fornece serviços em tempo de projeto. |
| DesignerAttribute(Type, Type) |
Inicializa uma nova instância da DesignerAttribute classe usando os tipos da classe base designer e designer. |
| DesignerAttribute(Type) |
Inicializa uma nova instância da DesignerAttribute classe usando o tipo que fornece serviços em tempo de design. |
Propriedades
| Name | Description |
|---|---|
| DesignerBaseTypeName |
Recebe o nome do tipo base deste designer. |
| DesignerTypeName |
Recebe o nome do tipo designer associado a este atributo designer. |
| 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 DesignerAttribute. |
| 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) |