共用方式為


VSProject.Events 屬性

更新:2007 年 11 月

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

命名空間:  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

屬性值

型別:VSLangProj.VSProjectEvents

VSProjectEvents 物件。

備註

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

範例

這個範例使用 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

使用權限

請參閱

參考

VSProject 介面

VSProject 成員

VSLangProj 命名空間