Share via


CustomTaskPaneCollection 類別 (2007 系統)

更新:2007 年 11 月

表示 Microsoft Office 應用程式中的自訂工作窗格集合。

命名空間:  Microsoft.Office.Tools
組件:  Microsoft.Office.Tools.Common.v9.0 (在 Microsoft.Office.Tools.Common.v9.0.dll 中)

語法

Public NotInheritable Class CustomTaskPaneCollection _
    Implements IEnumerable(Of CustomTaskPane), IEnumerable,  _
    ISupportInitialize, IDisposable

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

備註

您可使用應用程式層級增益集中的 CustomTaskPaneCollection 類別,將自訂工作窗格加入至應用程式、移除自訂工作窗格,或存取現有的自訂工作窗格。

請勿建立您自己的 CustomTaskPaneCollection 類別執行個體。請改用增益集專案中 ThisAddIn 類別的 CustomTaskPanes 欄位。如需 ThisAddIn 類別的詳細資訊,請參閱應用程式層級增益集程式設計AddIn 主項目

工作窗格係指通常停駐在應用程式視窗一側的使用者介面面板。如需如何建立自訂工作窗格的詳細資訊,請參閱自訂工作窗格概觀

範例

下列程式碼範例示範如何使用 Add(UserControl, String) 方法建立自訂工作窗格。此範例也使用 CustomTaskPane 物件的屬性來修改自訂工作窗格的預設外觀。這個程式碼範例是 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);
}

繼承階層架構

System.Object
  Microsoft.Office.Tools.CustomTaskPaneCollection

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。

請參閱

參考

CustomTaskPaneCollection 成員

Microsoft.Office.Tools 命名空間

其他資源

應用程式層級增益集程式設計

自訂工作窗格概觀

管理多個應用程式視窗中的自訂工作窗格

HOW TO:在應用程式中加入自訂工作窗格

逐步解說:運用自訂工作窗格自動化應用程式