CustomTaskPaneCollection Class (2007 System)

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

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

Syntax

'Declaration
Public NotInheritable Class CustomTaskPaneCollection _
    Implements IEnumerable(Of CustomTaskPane), IEnumerable,  _
    ISupportInitialize, IDisposable
'Usage
Dim instance As CustomTaskPaneCollection
public sealed class CustomTaskPaneCollection : IEnumerable<CustomTaskPane>, 
    IEnumerable, ISupportInitialize, IDisposable
public ref class CustomTaskPaneCollection sealed : IEnumerable<CustomTaskPane^>, 
    IEnumerable, ISupportInitialize, IDisposable
public final class CustomTaskPaneCollection implements IEnumerable<CustomTaskPane>, IEnumerable, ISupportInitialize, IDisposable

Remarks

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.

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 Programming Application-Level Add-Ins and AddIn Host Item.

Task panes are user interface panels that are typically docked to one side of an application window. For more information about how to create custom task panes, see Custom Task Panes Overview.

Examples

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 myUserControl1 As MyUserControl
Private WithEvents myCustomTaskPane As Microsoft.Office.Tools.CustomTaskPane

Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles Me.Startup

    myUserControl1 = New MyUserControl()
    myCustomTaskPane = Me.CustomTaskPanes.Add(myUserControl1, "New Task Pane")

    With myCustomTaskPane
        .DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionFloating
        .Height = 500
        .Width = 500
        .DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight
        .Width = 300
        .Visible = True 
    End With 
End Sub
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.DockPosition =
        Office.MsoCTPDockPosition.msoCTPDockPositionRight;
    myCustomTaskPane.Width = 300;

    myCustomTaskPane.Visible = true;
    myCustomTaskPane.DockPositionChanged +=
        new EventHandler(myCustomTaskPane_DockPositionChanged);
}

Inheritance Hierarchy

System.Object
  Microsoft.Office.Tools.CustomTaskPaneCollection

Thread Safety

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

See Also

Reference

CustomTaskPaneCollection Members

Microsoft.Office.Tools Namespace

Other Resources

Programming Application-Level Add-Ins

Custom Task Panes Overview

Managing Custom Task Panes in Multiple Application Windows

How to: Add a Custom Task Pane to an Application

Walkthrough: Automating an Application from a Custom Task Pane