更新: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
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。