共用方式為


VSProjectEvents.ImportsEvents 屬性

取得可用來存取 Imports 物件事件的 ImportsEvents 物件。

命名空間:  VSLangProj
組件:  VSLangProj (在 VSLangProj.dll 中)

語法

'宣告
ReadOnly Property ImportsEvents As ImportsEvents
    Get
ImportsEvents ImportsEvents { get; }
property ImportsEvents^ ImportsEvents {
    ImportsEvents^ get ();
}
abstract ImportsEvents : ImportsEvents
function get ImportsEvents () : ImportsEvents

屬性值

型別:VSLangProj.ImportsEvents
傳回 ImportsEvents 物件。

備註

ImportsEvents 物件可用來存取 ImportAddedImportRemoved 這兩個事件。

範例

這個範例使用 Events 物件將事件處理方法連接到特定專案的 ImportAddedImportRemoved

' Macro editor
' This example adds event handlers to the two events in
' ImportsEvents.
Imports VSLangProj
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 VSProject = CType(proj.Object, VSProject)
   Dim impEvents As ImportsEvents = vsproj.Events.ImportsEvents
   AddHandler impEvents.ImportAdded, AddressOf ImportAdded
   AddHandler impEvents.ImportRemoved, AddressOf ImportRemoved
End Sub

.NET Framework 安全性

請參閱

參考

VSProjectEvents 介面

VSLangProj 命名空間