共用方式為


VSProjectEvents.ReferencesEvents Property

Definition

Gets a ReferencesEvents object that provides access to the events of the References collection.

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

Property Value

Returns a ReferencesEvents object.

Attributes

Examples

This example connects event-handling methods for a specific project using the ReferencesEvents property.

' Macro Editor  
' Connects trivial methods to the ReferenceAdded and ReferenceDeleted  
' events of the first project in the solution.  
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  
   AddHandler refEvents.ReferenceRemoved, AddressOf ReferenceRemoved  
   AddHandler refEvents.ReferenceChanged, AddressOf ReferenceChanged  
End Sub  

Sub ReferenceRemoved(ByVal removedRef As Reference)  
   MsgBox("The reference for " & removedRef.Name & " was removed.")  
End Sub  

Sub ReferenceChanged(ByVal removedRef As Reference)  
   MsgBox("The reference for " & removedRef.Name & " was changed.")  
End Sub  

Sub ReferenceAdded(ByVal addedRef As Reference)  
   MsgBox("The reference for " & addedRef.Name & " was added.")  
End Sub  

Remarks

The ReferencesEvents property provides access to three events, ReferenceAdded, ReferenceChanged, and ReferenceRemoved.

Applies to