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 物件可用來存取 ImportAdded 和 ImportRemoved 這兩個事件。
範例
這個範例使用 Events 物件將事件處理方法連接到特定專案的 ImportAdded 和 ImportRemoved。
' 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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。