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