VSProject.Events 屬性
取得一個 VSProjectEvents 物件,可用來回應 Imports、References 和 BuildManager 物件的事件。
命名空間: VSLangProj
組件: VSLangProj (在 VSLangProj.dll 中)
語法
'宣告
ReadOnly Property Events As VSProjectEvents
VSProjectEvents Events { get; }
property VSProjectEvents^ Events {
VSProjectEvents^ get ();
}
abstract Events : VSProjectEvents with get
function get Events () : VSProjectEvents
屬性值
類型:VSLangProj.VSProjectEvents
VSProjectEvents 物件。
備註
Events 屬性可在 References、Imports 和 BuildManager 物件內用來存取事件。
範例
這個範例使用 Events 物件,將事件處理方法連接到特定專案的 ReferenceAdded 事件。 若要處理方案中所有專案的事件,請參閱 ReferencesEvents 物件。
[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
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。