Share via


ProjectHostItem.AddEventHandler Method

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

  • eventName
    Type: System.String

    The name of the event that was raised by target—for example, Click.

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

See Also

Reference

ProjectHostItem Class

ProjectHostItem Members

Microsoft.VisualStudio.Tools.Applications.DesignTime Namespace