共用方式為


VSProject2.Events 屬性

取得一個 VSProjectEvents 物件,可用來回應 ImportsReferencesBuildManager 物件的事件。

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

語法

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

屬性值

型別:VSLangProj.VSProjectEvents
VSProjectEvents 物件。

備註

Events 屬性可在 ReferencesImportsBuildManager 物件內用來存取事件。

範例

這個範例使用 Events 物件,將事件處理方法連接到特定專案的 ReferenceAdded 事件。若要處理方案中所有專案的事件,請參閱 ReferencesEvents 物件。如需其他範例,請參閱 HOW TO:回應在特定專案中的事件 (Visual Basic)HOW TO:回應在特定專案中的事件 (Visual C#)。若要將此範例當做巨集來執行,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例。開啟 Visual Basic 或 Visual C# 專案,再執行此範例。

[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
Imports VSLangProj80
Sub ConnectEvents()
   Dim proj As Project = DTE.Solution.Projects.Item(1)
   Dim vsproj As VSProject2 = CType(proj.Object, VSProject2)
   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 安全性

請參閱

參考

VSProject2 介面

Events 多載

VSLangProj80 命名空間

Events