DesignerAttribute Classe
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Specifica la classe utilizzata per implementare servizi in fase di progettazione per 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
- Ereditarietà
- Attributi
Esempio
Nell'esempio seguente viene creata una classe denominata MyForm.
MyForm dispone di due attributi, un DesignerAttribute oggetto che specifica questa classe usa e DocumentDesignerun DesignerCategoryAttribute oggetto che specifica la 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
Nell'esempio seguente viene creata un'istanza di MyForm. Ottiene quindi gli attributi per la classe , estrae DesignerAttributee stampa il nome della finestra di progettazione.
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
Commenti
La classe usata per i servizi in fase di progettazione deve implementare l'interfaccia IDesigner .
Utilizzare la DesignerBaseTypeName proprietà per trovare il tipo di base della finestra di progettazione. Utilizzare la DesignerTypeName proprietà per ottenere il nome del tipo di finestra di progettazione associato a questo membro.
Per altre informazioni, vedere Attributi.
Costruttori
| Nome | Descrizione |
|---|---|
| DesignerAttribute(String, String) |
Inizializza una nuova istanza della DesignerAttribute classe utilizzando il tipo di finestra di progettazione e la classe di base per la finestra di progettazione. |
| DesignerAttribute(String, Type) |
Inizializza una nuova istanza della DesignerAttribute classe utilizzando il nome della classe di progettazione e la classe di base per la finestra di progettazione. |
| DesignerAttribute(String) |
Inizializza una nuova istanza della DesignerAttribute classe utilizzando il nome del tipo che fornisce servizi in fase di progettazione. |
| DesignerAttribute(Type, Type) |
Inizializza una nuova istanza della DesignerAttribute classe utilizzando i tipi della finestra di progettazione e della classe di base della finestra di progettazione. |
| DesignerAttribute(Type) |
Inizializza una nuova istanza della DesignerAttribute classe utilizzando il tipo che fornisce servizi in fase di progettazione. |
Proprietà
| Nome | Descrizione |
|---|---|
| DesignerBaseTypeName |
Ottiene il nome del tipo di base di questa finestra di progettazione. |
| DesignerTypeName |
Ottiene il nome del tipo di finestra di progettazione associato a questo attributo della finestra di progettazione. |
| TypeId |
Ottiene un ID univoco per questo tipo di attributo. |
Metodi
| Nome | Descrizione |
|---|---|
| Equals(Object) |
Restituisce un valore che indica se il valore dell'oggetto specificato è uguale all'oggetto corrente DesignerAttribute. |
| GetHashCode() |
Restituisce il codice hash per questa istanza. |
| GetType() |
Ottiene il Type dell'istanza corrente. (Ereditato da Object) |
| IsDefaultAttribute() |
Quando sottoposto a override in una classe derivata, indica se il valore di questa istanza è il valore predefinito per la classe derivata. (Ereditato da Attribute) |
| Match(Object) |
Quando sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza è uguale a un oggetto specificato. (Ereditato da Attribute) |
| MemberwiseClone() |
Crea una copia superficiale del Objectcorrente. (Ereditato da Object) |
| ToString() |
Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |
Implementazioni dell'interfaccia esplicita
| Nome | Descrizione |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch. (Ereditato da Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Recupera le informazioni sul tipo per un oggetto, che può essere utilizzato per ottenere le informazioni sul tipo per un'interfaccia. (Ereditato da Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1). (Ereditato da Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Fornisce l'accesso alle proprietà e ai metodi esposti da un oggetto . (Ereditato da Attribute) |