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 命名空间