CustomTaskPaneCollection::Add Method (UserControl^, String^)
Creates a new CustomTaskPane and adds it to the current CustomTaskPaneCollection. The custom task pane is based on the specified UserControl and has the specified title.
Assembly: Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)
Parameters
- control
-
Type:
System.Windows.Forms::UserControl^
A UserControl that provides the user interface for the new custom task pane.
- title
-
Type:
System::String^
The text that appears in the title bar of the new custom task pane.
Return Value
Type: Microsoft.Office.Tools::CustomTaskPane^A CustomTaskPane that represents the new custom task pane.
| Exception | Condition |
|---|---|
| ArgumentNullException | control or title is null. |
| ObjectDisposedException | The M:Microsoft.Office.Tools.CustomTaskPaneCollection.Dispose method has already been called on the CustomTaskPaneCollection. |
Use this method to create a new CustomTaskPane that is associated with the active window of the Microsoft Office application.
Although a CustomTaskPaneCollection object is a collection of CustomTaskPane objects, the Add method accepts UserControl objects instead of CustomTaskPane objects. For more information, see Custom Task Panes.
If you want to specify a particular window and associate the custom task pane with it, use the Add(UserControl^, String^, Object^) method.
The following code example demonstrates how to create a custom task pane by using the Add(UserControl^, String^) method. The example also uses properties of the CustomTaskPane object to modify the default appearance of the custom task pane. This code example is part of a larger example provided for CustomTaskPane.