VSProject.Events 属性

获取 VSProjectEvents 对象,它使您可以响应 ImportsReferencesBuildManager 对象的事件。

命名空间:  VSLangProj
程序集:  VSLangProj(在 VSLangProj.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 对象。

[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 安全性

请参见

参考

VSProject 接口

VSLangProj 命名空间