VSProject2.Events2 Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a VSProjectEvents2 object that allows you to respond to events of the Imports, References, BuildManager, and VSLangProjWebReferencesEvents objects.
public:
property VSLangProj80::VSProjectEvents2 ^ Events2 { VSLangProj80::VSProjectEvents2 ^ get(); };
public:
property VSLangProj80::VSProjectEvents2 ^ Events2 { VSLangProj80::VSProjectEvents2 ^ get(); };
[System.Runtime.InteropServices.DispId(18)]
public VSLangProj80.VSProjectEvents2 Events2 { [System.Runtime.InteropServices.DispId(18)] get; }
[<System.Runtime.InteropServices.DispId(18)>]
[<get: System.Runtime.InteropServices.DispId(18)>]
member this.Events2 : VSLangProj80.VSProjectEvents2
Public ReadOnly Property Events2 As VSProjectEvents2
Property Value
A VSProjectEvents2 object.
- Attributes
Examples
This example connects an event-handling method to the ReferenceAdded event for a specific project by using the Events2 object. To handle events for all projects in a solution, see ReferencesEvents object. For Additional examples, see How to: Respond to Events in a Specific Project (Visual Basic) and How to: Respond to Events in a Specific Project (Visual C#). To run this example as a macro, see How to: Compile and Run the Automation Object Model Code Examples. Open a Visual Basic or Visual C# project before running this example.
[Visual Basic]
' Macro Editor
' This example connects a trivial function to the ReferenceAdded event,
' which is raised just after a reference is added to the project.
Imports VSLangProj
Imports VSLangProj80
Sub ConnectEvents()
Dim proj As Project = DTE.Solution.Projects.Item(1)
Dim vsproj As VSProject2 = CType(proj.Object, VSProject2)
Dim refEvents As ReferencesEvents = vsproj.Events2.ReferencesEvents
AddHandler refEvents.ReferenceAdded, AddressOf ReferenceAdded
End Sub
Sub ReferenceAdded(ByVal addedRef As Reference)
MsgBox("A reference for " & addedRef.Name & " was added.")
End Sub
Remarks
The Events2 property provides access to events from the References, Imports, BuildManager, and VSLangProjWebReferencesEvents objects.