Sdílet prostřednictvím


DesignerAttribute Třída

Definice

Určuje třídu použitou k implementaci služeb v době návrhu pro komponentu.

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
Dědičnost
DesignerAttribute
Atributy

Příklady

Následující příklad vytvoří třídu s názvem MyForm. MyForm má dva atributy, DesignerAttribute který určuje tuto třídu používá DocumentDesignera DesignerCategoryAttribute která určuje Form kategorii.

[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

Další příklad vytvoří instanci MyForm. Potom získá atributy pro třídu, extrahuje DesignerAttributea vytiskne název návrháře.

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

Poznámky

Třída, kterou používáte pro služby v době návrhu IDesigner , musí implementovat rozhraní.

DesignerBaseTypeName Pomocí vlastnosti vyhledejte základní typ návrháře. DesignerTypeName Vlastnost slouží k získání názvu typu návrháře přidruženého k tomuto členu.

Další informace naleznete v tématu Atributy.

Konstruktory

Name Description
DesignerAttribute(String, String)

Inicializuje novou instanci DesignerAttribute třídy pomocí typu návrháře a základní třídy pro návrháře.

DesignerAttribute(String, Type)

Inicializuje novou instanci DesignerAttribute třídy pomocí názvu třídy návrháře a základní třídy návrháře.

DesignerAttribute(String)

Inicializuje novou instanci DesignerAttribute třídy pomocí názvu typu, který poskytuje služby v době návrhu.

DesignerAttribute(Type, Type)

Inicializuje novou instanci DesignerAttribute třídy pomocí typů návrháře a návrhář základní třídy.

DesignerAttribute(Type)

Inicializuje novou instanci DesignerAttribute třídy pomocí typu, který poskytuje služby v době návrhu.

Vlastnosti

Name Description
DesignerBaseTypeName

Získá název základního typu tohoto návrháře.

DesignerTypeName

Získá název typu návrháře přidruženého k tomuto atributu návrháře.

TypeId

Získá jedinečné ID pro tento typ atributu.

Metody

Name Description
Equals(Object)

Vrátí, zda hodnota daného objektu je rovna aktuální DesignerAttribute.

GetHashCode()

Vrátí kód hash pro tuto instanci.

GetType()

Získá Type aktuální instance.

(Zděděno od Object)
IsDefaultAttribute()

Při přepsání v odvozené třídě určuje, zda hodnota této instance je výchozí hodnotou pro odvozenou třídu.

(Zděděno od Attribute)
Match(Object)

Při přepsání v odvozené třídě vrátí hodnotu, která určuje, zda se tato instance rovná zadanému objektu.

(Zděděno od Attribute)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Object.

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Explicitní implementace rozhraní

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

Mapuje sadu názvů na odpovídající sadu identifikátorů pro rozesílání.

(Zděděno od Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Načte informace o typu objektu, který lze použít k získání informací o typu pro rozhraní.

(Zděděno od Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Získá počet rozhraní typu informací, které objekt poskytuje (0 nebo 1).

(Zděděno od Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Poskytuje přístup k vlastnostem a metodám vystaveným objektem.

(Zděděno od Attribute)

Platí pro

Viz také