Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Adds an event handler to the host item's code file.
Namespace: Microsoft.VisualStudio.Tools.Applications.DesignTime
Assembly: Microsoft.VisualStudio.Tools.Applications.DesignTime.v9.0 (in Microsoft.VisualStudio.Tools.Applications.DesignTime.v9.0.dll)
Syntax
'Declaration
Public Sub AddEventHandler ( _
target As CodeExpression, _
eventName As String, _
listener As CodeExpression, _
method As CodeMemberMethod _
)
'Usage
Dim instance As ProjectHostItem
Dim target As CodeExpression
Dim eventName As String
Dim listener As CodeExpression
Dim method As CodeMemberMethod
instance.AddEventHandler(target, eventName, _
listener, method)
public void AddEventHandler(
CodeExpression target,
string eventName,
CodeExpression listener,
CodeMemberMethod method
)
public:
void AddEventHandler(
CodeExpression^ target,
String^ eventName,
CodeExpression^ listener,
CodeMemberMethod^ method
)
public 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.
Exceptions
| Exception | Condition |
|---|---|
| ParseException | The InternalStartup method of the host item's code file is not public. |
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 and 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
Microsoft.VisualStudio.Tools.Applications.DesignTime Namespace