DesignerAttribute Osztály

Definíció

Megadja az összetevő tervezési idejének megvalósításához használt osztályt.

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
Öröklődés
DesignerAttribute
Attribútumok

Példák

Az alábbi példa létrehoz egy osztályt MyForm. MyForm két attribútummal rendelkezik, az DesignerAttribute osztályt meghatározó osztály a DocumentDesigner, és egy DesignerCategoryAttribute , a kategóriát Form meghatározó attribútummal rendelkezik.

[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

A következő példa létrehoz egy példányt.MyForm Ezután lekéri az osztály attribútumait, kinyeri és DesignerAttributekinyomtatja a tervező nevét.

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

Megjegyzések

A tervezési idejű szolgáltatásokhoz használt osztálynak implementálnia kell a IDesigner felületet.

DesignerBaseTypeName A tulajdonság használatával keresse meg a tervező alaptípusát. DesignerTypeName A tulajdonság használatával lekérheti a taghoz társított tervezőtípus nevét.

További információ: Attribútumok.

Konstruktorok

Name Description
DesignerAttribute(String, String)

Inicializálja az osztály új példányát a DesignerAttribute tervező típusa és a tervező alaposztálya használatával.

DesignerAttribute(String, Type)

Inicializálja az DesignerAttribute osztály új példányát a tervezőosztály nevével és a tervező alaposztályával.

DesignerAttribute(String)

Inicializálja az DesignerAttribute osztály új példányát annak a típusnak a nevével, amely tervezési idejű szolgáltatásokat nyújt.

DesignerAttribute(Type, Type)

Inicializálja az osztály új példányát a DesignerAttribute tervezői és tervezői alaposztály típusával.

DesignerAttribute(Type)

Inicializálja az osztály új példányát a DesignerAttribute tervezési idejű szolgáltatásokat biztosító típus használatával.

Tulajdonságok

Name Description
DesignerBaseTypeName

Lekéri a tervező alaptípusának nevét.

DesignerTypeName

Lekéri a tervező attribútumhoz társított tervezőtípus nevét.

TypeId

Egyedi azonosítót kap ehhez az attribútumtípushoz.

Metódusok

Name Description
Equals(Object)

Azt adja vissza, hogy az adott objektum értéke megegyezik-e az aktuális DesignerAttributeértékkel.

GetHashCode()

A példány kivonatkódját adja vissza.

GetType()

Lekéri az Type aktuális példányt.

(Öröklődés forrása Object)
IsDefaultAttribute()

Ha egy származtatott osztályban felül van bírálva, azt jelzi, hogy a példány értéke-e a származtatott osztály alapértelmezett értéke.

(Öröklődés forrása Attribute)
Match(Object)

Származtatott osztály felülírásakor egy olyan értéket ad vissza, amely jelzi, hogy ez a példány egy adott objektummal egyenlő-e.

(Öröklődés forrása Attribute)
MemberwiseClone()

Az aktuális Objectpéldány sekély másolatát hozza létre.

(Öröklődés forrása Object)
ToString()

Az aktuális objektumot jelképező sztringet ad vissza.

(Öröklődés forrása Object)

Explicit interfész-implementációk

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

Névkészletet képez le a küldési azonosítók megfelelő készletére.

(Öröklődés forrása Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Lekéri egy objektum típusadatait, amelyek a felület típusadatainak lekérésére használhatók.

(Öröklődés forrása Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Lekéri az objektumok által biztosított típusinformációs felületek számát (0 vagy 1).

(Öröklődés forrása Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Hozzáférést biztosít az objektumok által közzétett tulajdonságokhoz és metódusokhoz.

(Öröklődés forrása Attribute)

A következőre érvényes:

Lásd még