IVstaProjectHostItem.AddEventHandler Method
Adds an event handler to the host item's code file.
Namespace: Microsoft.VisualStudio.Tools.Applications.DesignTime.Interop
Assembly: Microsoft.VisualStudio.Tools.Applications.DesignTime.v9.0 (in Microsoft.VisualStudio.Tools.Applications.DesignTime.v9.0.dll)
Syntax
'Declaration
Sub AddEventHandler ( _
target As CodeExpression, _
eventName As String, _
listener As CodeExpression, _
method As CodeMemberMethod _
)
'Usage
Dim instance As IVstaProjectHostItem
Dim target As CodeExpression
Dim eventName As String
Dim listener As CodeExpression
Dim method As CodeMemberMethod
instance.AddEventHandler(target, eventName, _
listener, method)
void AddEventHandler(
CodeExpression target,
string eventName,
CodeExpression listener,
CodeMemberMethod method
)
void AddEventHandler(
CodeExpression^ target,
String^ eventName,
CodeExpression^ listener,
CodeMemberMethod^ method
)
function AddEventHandler(
target : CodeExpression,
eventName : String,
listener : CodeExpression,
method : CodeMemberMethod
)
Parameters
target
Type: System.CodeDom.CodeExpressionThe source of the event—for example, Me.Button.
eventName
Type: System.StringThe name of the event that was raised by target—for example, Click.
listener
Type: System.CodeDom.CodeExpressionThe code needed to create the method that handles the event. Typically, this is an instance of CodeDelegateCreateExpression.
method
Type: System.CodeDom.CodeMemberMethodThe method to add.
Remarks
The AddEventHandler method inserts the method that is described in the method parameter, and adds a Handles clause to the method in Visual Basic or an advise statement in Visual C#.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
IVstaProjectHostItem Interface
Microsoft.VisualStudio.Tools.Applications.DesignTime.Interop Namespace