共用方式為


VSProjectEvents.ReferencesEvents 屬性

取得可用來存取 References 集合事件的 ReferencesEvents 物件。

命名空間:  VSLangProj
組件:  VSLangProj (在 VSLangProj.dll 中)

語法

'宣告
ReadOnly Property ReferencesEvents As ReferencesEvents
    Get
ReferencesEvents ReferencesEvents { get; }
property ReferencesEvents^ ReferencesEvents {
    ReferencesEvents^ get ();
}
abstract ReferencesEvents : ReferencesEvents
function get ReferencesEvents () : ReferencesEvents

屬性值

型別:VSLangProj.ReferencesEvents
傳回 ReferencesEvents 物件。

備註

ReferencesEvents 屬性可用來存取三個事件:ReferenceAddedReferenceChangedReferenceRemoved

範例

這個範例使用 ReferencesEvents 屬性將事件處理方法連接到特定專案。

' 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

.NET Framework 安全性

請參閱

參考

VSProjectEvents 介面

VSLangProj 命名空間