CustomTaskPaneCollection.Add メソッド (UserControl, String) (Microsoft.Office.Tools)

ビューの切り替え:
スクリプトなし
Visual Studio Tools for Office API Reference
CustomTaskPaneCollection.Add メソッド (UserControl, String)
この記事は翻訳者によって翻訳されたものです。 このページおよび元の英語コンテンツを同時に表示させるには、[ライトウェイト] に切り替えます。

新しい CustomTaskPane を作成し、現在の CustomTaskPaneCollection に追加します。 カスタム作業ウィンドウは、指定された UserControl に基づき、指定されたタイトルがあります。

名前空間:  Microsoft.Office.Tools
アセンブリ:  Microsoft.Office.Tools.Common (Microsoft.Office.Tools.Common.dll 内)
構文

Visual Basic
Function Add ( _
	control As UserControl, _
	title As String _
) As CustomTaskPane
C#
CustomTaskPane Add(
	UserControl control,
	string title
)

パラメーター

control
型: System.Windows.Forms.UserControl
新しいカスタム作業ウィンドウのユーザー インターフェイスを提供する UserControl
title
型: System.String
新しいカスタム作業ウィンドウのタイトル バーに表示されるテキスト。

戻り値

型: Microsoft.Office.Tools.CustomTaskPane
新しいカスタム作業ウィンドウを表す CustomTaskPane
例外

例外 条件
ArgumentNullException

control または titlenull です。

ObjectDisposedException

Dispose() メソッドは既に、CustomTaskPaneCollection で呼び出されています。

解説

Microsoft Office アプリケーションのアクティブなウィンドウに関連付けられている新しい CustomTaskPane を作成するには、このメソッドを使用します。

CustomTaskPaneCollection オブジェクトは CustomTaskPane オブジェクトのコレクションですが、Add メソッドは、CustomTaskPane オブジェクトではなく UserControl オブジェクトを受け入れます。 詳細については、「カスタム作業ウィンドウの概要」を参照してください。

特定のウィンドウを指定し、そのウィンドウにカスタム作業ウィンドウを関連付けるには、Add(UserControl, String, Object) メソッドを使用します。


次のコード例は、Add(UserControl, String) メソッドを使用してカスタム作業ウィンドウを作成する方法を示します。 また、このコード例では、CustomTaskPane オブジェクトのプロパティを使用してカスタム作業ウィンドウの既定の外観を変更します。 このコード例は、CustomTaskPane のトピックで取り上げているコード例の一部分です。

Visual Basic

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


C#

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


.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。
参照

参照