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, který DesignerAttribute určuje, že tato třída používá DocumentDesigner, a , 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 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 = 
       (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žijete pro služby v době návrhu IDesigner , musí implementovat rozhraní .

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

Další informace najdete v tématu Atributy.

Konstruktory

DesignerAttribute(String)

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

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 pro návrháře.

DesignerAttribute(Type)

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

DesignerAttribute(Type, Type)

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

Vlastnosti

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

Equals(Object)

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

GetHashCode()

Vrátí hodnotu hash pro tuto instanci.

GetType()

Type Získá z aktuální instance.

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

Při přepsání v odvozené třídě označuje, zda je hodnota této instance 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á označuje, zda se tato instance rovná zadanému objektu.

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

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

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

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

(Zděděno od Object)

Explicitní implementace rozhraní

_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é