Share via


VSProject.Events Property

Definition

Gets a VSProjectEvents object that allows you to respond to events of the Imports, References, and BuildManager objects.

public:
 property VSLangProj::VSProjectEvents ^ Events { VSLangProj::VSProjectEvents ^ get(); };
public:
 property VSLangProj::VSProjectEvents ^ Events { VSLangProj::VSProjectEvents ^ get(); };
[System.Runtime.InteropServices.DispId(12)]
public VSLangProj.VSProjectEvents Events { [System.Runtime.InteropServices.DispId(12)] get; }
[<System.Runtime.InteropServices.DispId(12)>]
[<get: System.Runtime.InteropServices.DispId(12)>]
member this.Events : VSLangProj.VSProjectEvents
Public ReadOnly Property Events As VSProjectEvents

Property Value

A VSProjectEvents object.

Attributes

Examples

This example connects an event-handling method to the ReferenceAdded event for a specific project using the Events object. To handle events for all projects in a solution, see ReferencesEvents object.

[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  
Sub ConnectEvents()  
   Dim proj As Project = DTE.Solution.Projects.Item(1)  
   Dim vsproj As VSProject = CType(proj.Object, VSProject)  
   Dim refEvents As ReferencesEvents = vsproj.Events.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 Events property provides access to events from the References, Imports, and BuildManager objects.

Applies to