CodeAttachEventStatement Classe
In questo articolo
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.
Rappresenta un'istruzione che consente di associare un delegato gestore eventi a un evento.
public ref class CodeAttachEventStatement : System::CodeDom::CodeStatement
public class CodeAttachEventStatement : System.CodeDom.CodeStatement
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeAttachEventStatement : System.CodeDom.CodeStatement
type CodeAttachEventStatement = class
inherit CodeStatement
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeAttachEventStatement = class
inherit CodeStatement
Public Class CodeAttachEventStatement
Inherits CodeStatement
- Ereditarietà
- Attributi
Il codice di esempio seguente illustra l'uso di un CodeAttachEventStatement oggetto per associare un gestore eventi a un evento.
// Defines a delegate creation expression that creates an EventHandler delegate pointing to a method named TestMethod.
CodeDelegateCreateExpression^ createDelegate1 = gcnew CodeDelegateCreateExpression( gcnew CodeTypeReference( "System.EventHandler" ),gcnew CodeThisReferenceExpression,"TestMethod" );
// Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event.
CodeAttachEventStatement^ attachStatement1 = gcnew CodeAttachEventStatement( gcnew CodeThisReferenceExpression,"TestEvent",createDelegate1 );
// A C# code generator produces the following source code for the preceeding example code:
// this.TestEvent += new System.EventHandler(this.TestMethod);
// Defines a delegate creation expression that creates an EventHandler delegate pointing to a method named TestMethod.
CodeDelegateCreateExpression createDelegate1 = new CodeDelegateCreateExpression(
new CodeTypeReference( "System.EventHandler" ), new CodeThisReferenceExpression(), "TestMethod" );
// Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event.
CodeAttachEventStatement attachStatement1 = new CodeAttachEventStatement( new CodeThisReferenceExpression(), "TestEvent", createDelegate1 );
// A C# code generator produces the following source code for the preceeding example code:
// this.TestEvent += new System.EventHandler(this.TestMethod);
' Defines a delegate creation expression that creates an EventHandler delegate pointing to TestMethod.
Dim createDelegate1 As New CodeDelegateCreateExpression(New CodeTypeReference("System.EventHandler"), New CodeThisReferenceExpression(), "TestMethod")
' Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event.
Dim attachStatement1 As New CodeAttachEventStatement(New CodeThisReferenceExpression(), "TestEvent", createDelegate1)
' A Visual Basic code generator produces the following source code for the preceeding example code:
' AddHandler TestEvent, AddressOf Me.TestMethod
CodeAttachEventStatement può essere usato per rappresentare un'istruzione che aggiunge un delegato del gestore eventi per un evento. La Event proprietà indica l'evento a cui collegare il gestore eventi. La Listener proprietà indica il gestore eventi da associare.
Code |
Inizializza una nuova istanza della classe CodeAttachEventStatement. |
Code |
Inizializza una nuova istanza della classe CodeAttachEventStatement utilizzando l'evento e il delegato specificati. |
Code |
Inizializza una nuova istanza della classe CodeAttachEventStatement utilizzando l'oggetto specificato che contiene l'evento, il nome dell'evento e il delegato gestore eventi. |
End |
Ottiene un oggetto CodeDirectiveCollection contenente le direttive finali. (Ereditato da CodeStatement) |
Event |
Ottiene o imposta l'evento al quale associare un delegato gestore eventi. |
Line |
Ottiene o imposta la riga in cui si verifica l'istruzione di codice. (Ereditato da CodeStatement) |
Listener |
Ottiene o imposta il nuovo delegato gestore eventi da associare all'evento. |
Start |
Ottiene un oggetto CodeDirectiveCollection contenente le direttive iniziali. (Ereditato da CodeStatement) |
User |
Ottiene i dati definibili dall'utente per l'oggetto corrente. (Ereditato da CodeObject) |
Equals(Object) |
Determina se l'oggetto specificato è uguale all'oggetto corrente. (Ereditato da Object) |
Get |
Funge da funzione hash predefinita. (Ereditato da Object) |
Get |
Ottiene l'oggetto Type dell'istanza corrente. (Ereditato da Object) |
Memberwise |
Crea una copia superficiale dell'oggetto Object corrente. (Ereditato da Object) |
To |
Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: