CustomTaskPaneCollection::Remove Method (CustomTaskPane^)
Removes the specified CustomTaskPane from the CustomTaskPaneCollection.
Assembly: Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)
Parameters
- customTaskPane
-
Type:
Microsoft.Office.Tools::CustomTaskPane^
The CustomTaskPane to remove from the collection.
Return Value
Type: System::Booleantrue if the CustomTaskPane was successfully removed from the collection; false if the collection does not contain the specified CustomTaskPane.
| Exception | Condition |
|---|---|
| ArgumentNullException | customTaskPane is null. |
| ObjectDisposedException | The M:Microsoft.Office.Tools.CustomTaskPaneCollection.Dispose method has already been called on the CustomTaskPaneCollection. |
If your add-in no longer requires a custom task pane, you can use the Remove method to clean up resources used by the task pane while the add-in is still running. When you use this method, the M:Microsoft.Office.Tools.CustomTaskPane.Dispose method of the specified CustomTaskPane object is automatically called.
The Visual Studio Tools for Office runtime automatically cleans up resources used by the custom task pane when the add-in is unloaded. Do not call the Remove method in the ThisAddIn_Shutdown event handler in your project. This method will throw an ObjectDisposedException, because the Visual Studio Tools for Office runtime cleans up resources used by the CustomTaskPane object before ThisAddIn_Shutdown is called.