Export (0) Print
Expand All

ImportsEvents Interface

Provides access to events that are raised when a project Imports statement is added to or deleted from a Visual Basic project. Use this object for functionality and refer to ImportsEventsClass for this object’s documentation.

Namespace:  VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)

[GuidAttribute("037AD859-7A75-4CF3-8A38-83D6E045FEE3")]
public interface ImportsEvents : _ImportsEvents, 
	_dispImportsEvents_Event

The ImportsEvents type exposes the following members.

  NameDescription
Public methodadd_ImportAddedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispImportsEvents_Event.)
Public methodadd_ImportRemovedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispImportsEvents_Event.)
Public methodremove_ImportAddedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispImportsEvents_Event.)
Public methodremove_ImportRemovedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispImportsEvents_Event.)
Top

  NameDescription
Public eventImportAddedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispImportsEvents_Event.)
Public eventImportRemovedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispImportsEvents_Event.)
Top

The ImportsEvents object may be accessed from either the VSProject object or the DTE object. Each project, through the VSProject object, has an ImportsEvents object providing access to the events of that project. The ImportsEvents object of the DTE object may be used to connect to events of individual projects or to events of all Visual Basic projects in the solution.

The following two examples use the late-bound VBImportsEvents property to connect to Visual Basic project events.

There are two late-bound methods for handling events. The first method allows you to connect to events for a particular project and requires the Option Strict Off statement to compile. This method returns an error if the parameter to the VBImportsEvents call is not of type Project. The parameter to VBImportsEvents is optional. If it is omitted, events for all the Visual Basic projects in the solution are received.

' Macro editor
Option Strict Off
Imports VSLangProj
Dim WithEvents importEvents As ImportsEvents
Sub ConnectAllImportEvents()
   Dim proj As Project = DTE.Solution.Projects.Item(1)
   importEvents = DTE.Events.VBImportsEvents(proj)
End Sub 

Public Sub importEvents_ImportAdded(ByVal bstrImport As String) _
Handles importEvents.ImportAdded
   MsgBox(bstrImport)
End Sub

The second late-bound method allows you to add event-handling methods for events in all the projects in the solution. This method does not offer a way to filter events for only a particular project. It will compile with Option Strict On.

' Macro editor
Imports VSLangProj
Dim WithEvents importEvents As ImportsEvents
Sub ConnectProjectImportEvents()
   importEvents = CType(DTE.Events.GetObject("VBImportsEvents"), _
      ImportsEvents)
End Sub

Public Sub importEvents_ImportAdded(ByVal bstrImport As String) _
Handles importEvents.ImportAdded
   MsgBox(bstrImport)
End Sub
Show:
© 2014 Microsoft