CustomTaskPaneCollection.Add Method (UserControl, String, Object)

 

Creates a new CustomTaskPane and adds it to the current CustomTaskPaneCollection. The custom task pane is based on the specified UserControl, has the specified title, and is associated with the specified application window.

Namespace:   Microsoft.Office.Tools
Assembly:  Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)

CustomTaskPane Add(
	UserControl control,
	string title,
	object window
)

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.

window
Type: System.Object

An object that represents the application window to associate the new custom task pane with.

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

Use this method to create a new CustomTaskPane that is associated with a specific application window. This method is useful if you want to create custom task panes that are visible with multiple Inspectors or Explorers in Outlook, or with multiple documents in Word or InfoPath.

The type of the window parameter depends on the application. The following table lists the valid types of the window parameter.

Application

Parameter type

Word

Microsoft.Office.Interop.Word.Window

Excel

Microsoft.Office.Interop.Excel.Window

PowerPoint

Microsoft.Office.Interop.PowerPoint.DocumentWindow

InfoPath

T:Microsoft.Office.Interop.InfoPath.WindowObject

Outlook

Microsoft.Office.Interop.Outlook.Explorer

-or-

Microsoft.Office.Interop.Outlook.Inspector

Although a CustomTaskPaneCollection is a collection of CustomTaskPane objects, the Add method accepts UserControl objects instead of CustomTaskPane objects. For more information, see Custom Task Panes.

Return to top
Show: