ImportsEvents Interface

Definition

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.

public interface class ImportsEvents : VSLangProj::_dispImportsEvents_Event, VSLangProj::_ImportsEvents
public interface class ImportsEvents : VSLangProj::_dispImportsEvents_Event, VSLangProj::_ImportsEvents
__interface ImportsEvents : VSLangProj::_dispImportsEvents_Event, VSLangProj::_ImportsEvents
[System.Runtime.InteropServices.CoClass(typeof(VSLangProj.ImportsEventsClass))]
[System.Runtime.InteropServices.Guid("037AD859-7A75-4CF3-8A38-83D6E045FEE3")]
public interface ImportsEvents : VSLangProj._dispImportsEvents_Event, VSLangProj._ImportsEvents
[System.Runtime.InteropServices.CoClass(typeof(VSLangProj.ImportsEventsClass))]
[System.Runtime.InteropServices.Guid("037AD859-7A75-4CF3-8A38-83D6E045FEE3")]
[System.Runtime.InteropServices.ComVisible(false)]
public interface ImportsEvents : VSLangProj._dispImportsEvents_Event, VSLangProj._ImportsEvents
[<System.Runtime.InteropServices.CoClass(typeof(VSLangProj.ImportsEventsClass))>]
[<System.Runtime.InteropServices.Guid("037AD859-7A75-4CF3-8A38-83D6E045FEE3")>]
type ImportsEvents = interface
    interface _ImportsEvents
    interface _dispImportsEvents_Event
[<System.Runtime.InteropServices.CoClass(typeof(VSLangProj.ImportsEventsClass))>]
[<System.Runtime.InteropServices.Guid("037AD859-7A75-4CF3-8A38-83D6E045FEE3")>]
[<System.Runtime.InteropServices.ComVisible(false)>]
type ImportsEvents = interface
    interface _ImportsEvents
    interface _dispImportsEvents_Event
Public Interface ImportsEvents
Implements _dispImportsEvents_Event, _ImportsEvents
Derived
Attributes
Implements

Examples

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  

Remarks

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.

Methods

add_ImportAdded(_dispImportsEvents_ImportAddedEventHandler)

Microsoft Internal Use Only.

(Inherited from _dispImportsEvents_Event)
add_ImportRemoved(_dispImportsEvents_ImportRemovedEventHandler)

Microsoft Internal Use Only.

(Inherited from _dispImportsEvents_Event)
remove_ImportAdded(_dispImportsEvents_ImportAddedEventHandler)

Microsoft Internal Use Only.

(Inherited from _dispImportsEvents_Event)
remove_ImportRemoved(_dispImportsEvents_ImportRemovedEventHandler)

Microsoft Internal Use Only.

(Inherited from _dispImportsEvents_Event)

Events

ImportAdded

This API supports the product infrastructure and is not intended to be used directly from your code.

Microsoft Internal Use Only.

(Inherited from _dispImportsEvents_Event)
ImportRemoved

This API supports the product infrastructure and is not intended to be used directly from your code.

Microsoft Internal Use Only.

(Inherited from _dispImportsEvents_Event)

Applies to