CustomTaskPaneCollection.Remove 方法

將指定的 CustomTaskPaneCustomTaskPaneCollection 中移除。

命名空間:  Microsoft.Office.Tools
組件:  Microsoft.Office.Tools.Common (在 Microsoft.Office.Tools.Common.dll 中)

語法

'宣告
Function Remove ( _
    customTaskPane As CustomTaskPane _
) As Boolean
bool Remove(
    CustomTaskPane customTaskPane
)

參數

傳回值

型別:System.Boolean
如果已成功從集合中移除 CustomTaskPane,則為 true;如果集合未包含指定的 CustomTaskPane,則為 false。

例外狀況

例外狀況 條件
ArgumentNullException

customTaskPane 為 nullNull 參照 (即 Visual Basic 中的 Nothing)。

ObjectDisposedException

已經在 CustomTaskPaneCollection 上呼叫過 Dispose() 方法。

備註

如果增益集不再需要自訂工作窗格,您可以在增益集仍執行時使用 Remove 方法清除工作窗格所使用的資源。 當您使用這個方法時,會自動呼叫指定之 CustomTaskPane 物件的 Dispose() 方法。

當增益集卸載時,Visual Studio Tools for Office Runtime 會自動清除自訂工作窗格使用的資源。 請不要在專案的 ThisAddIn_Shutdown 事件處理常式中呼叫 Remove 方法。 此方法會擲回 ObjectDisposedException,因為 Visual Studio Tools for Office Runtime 會在呼叫 ThisAddIn_Shutdown 之前先清除 CustomTaskPane 物件使用的資源。

.NET Framework 安全性

請參閱

參考

CustomTaskPaneCollection 介面

Microsoft.Office.Tools 命名空間