Compartir por


DesignerAttribute Clase

Definición

Especifica la clase que se usa para implementar servicios en tiempo de diseño para un 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
Herencia
DesignerAttribute
Atributos

Ejemplos

En el ejemplo siguiente se crea una clase denominada MyForm. MyForm tiene dos atributos, un DesignerAttribute que especifica esta clase usa , DocumentDesignery que DesignerCategoryAttribute especifica la Form categoría .

[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

En el ejemplo siguiente se crea una instancia de MyForm. A continuación, obtiene los atributos de la clase , extrae DesignerAttributey imprime el nombre del diseñador.

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

Comentarios

La clase que se usa para los servicios en tiempo de diseño debe implementar la IDesigner interfaz .

Use la DesignerBaseTypeName propiedad para buscar el tipo base del diseñador. Utilice la DesignerTypeName propiedad para obtener el nombre del tipo de diseñador asociado a este miembro.

Para obtener más información, consulte Attributes (Atributos).

Constructores

Nombre Description
DesignerAttribute(String, String)

Inicializa una nueva instancia de la DesignerAttribute clase mediante el tipo de diseñador y la clase base para el diseñador.

DesignerAttribute(String, Type)

Inicializa una nueva instancia de la DesignerAttribute clase utilizando el nombre de la clase de diseñador y la clase base para el diseñador.

DesignerAttribute(String)

Inicializa una nueva instancia de la DesignerAttribute clase utilizando el nombre del tipo que proporciona servicios en tiempo de diseño.

DesignerAttribute(Type, Type)

Inicializa una nueva instancia de la DesignerAttribute clase utilizando los tipos de la clase base del diseñador y del diseñador.

DesignerAttribute(Type)

Inicializa una nueva instancia de la DesignerAttribute clase mediante el tipo que proporciona servicios en tiempo de diseño.

Propiedades

Nombre Description
DesignerBaseTypeName

Obtiene el nombre del tipo base de este diseñador.

DesignerTypeName

Obtiene el nombre del tipo de diseñador asociado a este atributo de diseñador.

TypeId

Obtiene un identificador único para este tipo de atributo.

Métodos

Nombre Description
Equals(Object)

Devuelve si el valor del objeto especificado es igual al actual DesignerAttribute.

GetHashCode()

Devuelve el código hash de esta instancia.

GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
IsDefaultAttribute()

Cuando se reemplaza en una clase derivada, indica si el valor de esta instancia es el valor predeterminado de la clase derivada.

(Heredado de Attribute)
Match(Object)

Cuando se reemplaza en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.

(Heredado de Attribute)
MemberwiseClone()

Crea una copia superficial del Objectactual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Implementaciones de interfaz explícitas

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

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.

(Heredado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera la información de tipo de un objeto, que se puede usar para obtener la información de tipo de una interfaz.

(Heredado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).

(Heredado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a propiedades y métodos expuestos por un objeto .

(Heredado de Attribute)

Se aplica a

Consulte también