CustomTaskPaneCollection.Add Yöntem (UserControl, String)
Yeni bir oluşturur CustomTaskPane Geçerli ekler ve CustomTaskPaneCollection. Özel görev bölmesini temel üzerinde belirtilen UserControl ve belirtilen bir başlık.
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
- control
Tür: System.Windows.Forms.UserControl
A UserControl sağlayan kullanıcı arabirimi için yeni özel görev bölmesi.
- 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 temsil eden yeni özel görev bölmesi.
Özel Durumlar
Exception | Koşul |
---|---|
ArgumentNullException | controlor title is nullnull başvuru (Visual Basic\'te Nothing). |
ObjectDisposedException | Dispose() Yöntemi zaten adlı üzerinde CustomTaskPaneCollection. |
Açıklamalar
Yeni bir oluşturmak için bu yöntemi kullanın CustomTaskPane ilişkili etkin pencere Microsoft Office uygulaması.
Rağmen bir CustomTaskPaneCollection nesnedir topluluğu CustomTaskPane nesneleri, Add yöntemi kabul UserControl nesneler yerine CustomTaskPane nesneler. Daha fazla bilgi için bkz. Özel Görev Bölmelerine Genel Bakış.
Belirli bir pencere belirtin ve özel görev bölmesi ile ilişkilendirmek kullanın, isterseniz, Add(UserControl, String, Object) yöntemi.
Örnekler
Aşağıdaki kod örneği, bir özel görev bölmesini kullanarak oluşturmak gösterilmiştir Add(UserControl, String) yöntemi. Örnek özelliklerini de kullanır CustomTaskPane nesne değiştirme varsayılan görünümünü özel görev bölmesi. Bu kod örneği için sağlanan büyük bir örnek bir 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
- Anında arayanlar için tam güven. Bu üye kısmen güvenilen kodla kullanılamaz. Daha fazla bilgi için bkz. kısmen güvenilir kod tarafından Kitaplıklar kullanma.