Share via


CustomTaskPaneCollection Interface

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

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

Syntax

'Declaration
<GuidAttribute("c3a84bf1-e95b-4d23-952d-59e35673958e")> _
Public Interface CustomTaskPaneCollection _
    Inherits IEnumerable(Of CustomTaskPane), IEnumerable, IDisposable
[GuidAttribute("c3a84bf1-e95b-4d23-952d-59e35673958e")]
public interface CustomTaskPaneCollection : IEnumerable<CustomTaskPane>, 
    IEnumerable, IDisposable

The CustomTaskPaneCollection type exposes the following members.

Properties

  Name Description
Public property Count Gets the number of CustomTaskPane objects in the current CustomTaskPaneCollection.
Public property Item Gets the CustomTaskPane at the specified index.

Top

Methods

  Name Description
Public method Add(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.
Public method Add(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.
Public method BeginInit Infrastructure.
Public method Dispose Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Inherited from IDisposable.)
Public method EndInit Infrastructure.
Public method GetEnumerator Returns an enumerator that iterates through the collection. (Inherited from IEnumerable<CustomTaskPane>.)
Public method Remove Removes the specified CustomTaskPane from the CustomTaskPaneCollection.
Public method RemoveAt Removes the CustomTaskPane at the specified index of the CustomTaskPaneCollection.

Top

Remarks

Use the CustomTaskPaneCollection object 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. To access the CustomTaskPaneCollection object, use the CustomTaskPanes field of the ThisAddIn class in your add-in project. For more information, see Programming Application-Level Add-Ins.

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.

Note

This interface is implemented by the Visual Studio Tools for Office runtime. It is not intended to be implemented in your code. For more information, see Visual Studio Tools for Office Runtime Overview.

Usage

This documentation describes the version of this type that is used in Office projects that target the .NET Framework 4. In projects that target the .NET Framework 3.5, this type might have different members and the code examples provided for this type might not work. For documentation about this type in projects that target the .NET Framework 3.5, see the following reference section in the Visual Studio 2008 documentation: https://go.microsoft.com/fwlink/?LinkId=160658.

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

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);
}

See Also

Reference

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