This documentation is archived and is not being maintained.

CustomTaskPaneCollection Class

Represents a collection of custom task panes in a Microsoft Office application.

Namespace: Microsoft.Office.Tools
Assembly: Microsoft.Office.Tools.Common2007 (in microsoft.office.tools.common2007.dll)

public sealed class CustomTaskPaneCollection : IEnumerable<CustomTaskPane>, IEnumerable, 
	ISupportInitialize, IDisposable

Use the CustomTaskPaneCollection class in an application-level add-in to add a custom task pane to an application, remove a custom task pane, or access an existing custom task pane. Task panes are user interface panels that are typically docked to one side of an application window. For more information about creating custom task panes, see Custom Task Panes Overview.

Do not create your own instance of the CustomTaskPaneCollection class. Instead, use the CustomTaskPanes field of the ThisAddIn class in your add-in project. For more information about the ThisAddIn class, see Getting Started Programming Application-Level Add-ins and AddIn.

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 the CustomTaskPane class.

private MyUserControl myUserControl1;
private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    myUserControl1 = new MyUserControl();
    myCustomTaskPane = this.CustomTaskPanes.Add(myUserControl1, 
        "New Task Pane");

    myCustomTaskPane.DockPosition =
        Office.MsoCTPDockPosition.msoCTPDockPositionFloating;
    myCustomTaskPane.Height = 500;
    myCustomTaskPane.Width = 500;
    myCustomTaskPane.DockPositionRestrict =
        Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;
    myCustomTaskPane.Visible = true;

    myCustomTaskPane.VisibleChanged += 
        new EventHandler(myCustomTaskPane_VisibleChanged);
    myCustomTaskPane.DockPositionChanged += 
        new EventHandler(myCustomTaskPane_DockPositionChanged);
}

System.Object
  Microsoft.Office.Tools.CustomTaskPaneCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: