CustomTaskPaneCollection.Remove(CustomTaskPane) 方法

定义

CustomTaskPane 中移除指定的 CustomTaskPaneCollection

public bool Remove (Microsoft.Office.Tools.CustomTaskPane customTaskPane);

参数

customTaskPane
CustomTaskPane

要从该集合中移除的 CustomTaskPane

返回

Boolean

如果从集合中成功移除了 CustomTaskPane,则为 true;如果集合中不包含指定的 CustomTaskPane,则为 false

例外

customTaskPanenull

已在 CustomTaskPaneCollection 上调用 Microsoft.Office.Tools.CustomTaskPaneCollection.Dispose 方法。

注解

如果外接程序不再需要自定义任务窗格,则可以使用 Remove 方法清理加载项仍在运行时任务窗格使用的资源。 使用此方法时,将 <xref:Microsoft.Office.Tools.CustomTaskPane.Dispose%2A> CustomTaskPane 自动调用指定对象的方法。

Visual Studio Tools for Office Runtime卸载外接程序时,会自动清理自定义任务窗格使用的资源。 不要在 Remove ThisAddIn_Shutdown 项目中的事件处理程序中调用方法。 此方法将引发 ObjectDisposedException ,因为在 Visual Studio Tools for Office Runtime CustomTaskPane 调用之前会清除对象使用的资源 ThisAddIn_Shutdown

适用于