共用方式為


VSProjectEvents.ReferencesEvents 屬性

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

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

語法

'宣告
ReadOnly Property ReferencesEvents As ReferencesEvents
'用途
Dim instance As VSProjectEvents
Dim value As ReferencesEvents

value = instance.ReferencesEvents
ReferencesEvents ReferencesEvents { get; }
property ReferencesEvents^ ReferencesEvents {
    ReferencesEvents^ get ();
}
/** @property */
ReferencesEvents get_ReferencesEvents ()
function get ReferencesEvents () : 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

請參閱

參考

VSProjectEvents 介面
VSProjectEvents 成員
VSLangProj 命名空間