Aracılığıyla paylaş


CustomTaskPaneCollection.Add Yöntem (UserControl, String)

Yeni bir oluşturur CustomTaskPane ve geçerli ekler CustomTaskPaneCollection.Özel görev bölmesini temel üzerinde belirtilen UserControl ve belirtilen başlığa sahip.

Ad alanı:  Microsoft.Office.Tools
Derleme:  Microsoft.Office.Tools.Common (Microsoft.Office.Tools.Common.dll içinde)

Sözdizimi

'Bildirim
Function Add ( _
    control As UserControl, _
    title As String _
) As CustomTaskPane
CustomTaskPane Add(
    UserControl control,
    string title
)

Parametreler

  • title
    Tür: System.String
    Yeni özel görev bölmesinin başlık çubuğunda beliren metindir.

Dönüş Değeri

Tür: Microsoft.Office.Tools.CustomTaskPane
A CustomTaskPane yeni bir özel görev bölmesini temsil eden.

Özel Durumlar

Exception Koşul
ArgumentNullException

controlor title is nullnull başvuru (Visual Basic'te Nothing).

ObjectDisposedException

Dispose Yöntemi zaten çağrıldıktan üzerinde CustomTaskPaneCollection.

Notlar

Yeni bir oluşturmak için bu yöntemi kullanın CustomTaskPane Microsoft Office uygulamasının etkin pencere ile ilişkili.

Ancak bir CustomTaskPaneCollection nesne topluluğudur CustomTaskPane nesneleri, Add yöntemi kabul eder UserControl yerine nesneleri CustomTaskPane nesneler.Daha fazla bilgi için bkz. Özel Görev Bölmeleri.

İsterseniz belirli bir penceresi belirtin ve onunla birlikte özel görev bölmesini ilişkilendirmek kullanın Add(UserControl, String, Object) yöntem.

Örnekler

Aşağıdaki kod örneği kullanarak özel görev bölmesi oluşturmak nasıl gösterir Add(UserControl, String) yöntem.Örnek özelliklerini de kullanır CustomTaskPane özel görev bölmesini varsayılan görünümünü değiştirmek için nesne.Bu kod örneği için sağlanan daha büyük bir örneğin parçasıdır 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);
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

CustomTaskPaneCollection Arabirim

Add Fazla Yük

Microsoft.Office.Tools Ad Alanı