ImportsEvents Property
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

VSProjectEvents2.ImportsEvents Property 

Gets an ImportsEvents object that provides access to the Imports object events.

Namespace: VSLangProj80
Assembly: VSLangProj80 (in vslangproj80.dll)

ImportsEvents ImportsEvents { get; }
/** @property */
ImportsEvents get_ImportsEvents ()

function get ImportsEvents () : ImportsEvents

Property Value

An ImportsEvents object.

The ImportsEvents object provides access to two events, ImportAdded and ImportRemoved.

This example connects event-handling methods to the ImportAdded and ImportRemoved events for a specific project by using the Events object. For more information about how to run macro samples, see How to: Compile and Run the Automation Object Model Code Examples.

Open a Visual Basic, Visual C#, or Visual J# project before running this macro.

' Macro editor
' This example adds event handlers to the two events in
' ImportsEvents.
Imports VSLangProj
Imports VSLangProj80
Sub ImportAdded(ByVal addedImport As String)
   MsgBox("The import '" & addedImport & "' was added.")
End Sub

Sub ImportRemoved(ByVal removedImport As String)
   MsgBox("The import '" & removedImport & "' was removed.")
End Sub

Sub ConnectImportsEvents()
   Dim proj As Project = DTE.Solution.Projects.Item(1)
   Dim vsproj As VSProject2 = CType(proj.Object, VSProject2)
   Dim impEvents As ImportsEvents = vsproj.Events.ImportsEvents
   AddHandler impEvents.ImportAdded, AddressOf ImportAdded
   AddHandler impEvents.ImportRemoved, AddressOf ImportRemoved
End Sub
© 2016 Microsoft