Freigeben über


CustomTaskPane.Control-Eigenschaft

Ruft das UserControl ab, das die Benutzeroberfläche des benutzerdefinierten Aufgabenbereichs bereitstellt.

Namespace:  Microsoft.Office.Tools
Assembly:  Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)

Syntax

'Declaration
ReadOnly Property Control As UserControl
UserControl Control { get; }

Eigenschaftswert

Typ: System.Windows.Forms.UserControl
Das UserControl, das die Benutzeroberfläche des benutzerdefinierten Aufgabenbereichs bereitstellt.

Ausnahmen

Ausnahme Bedingung
ObjectDisposedException

Die Dispose-Methode des CustomTaskPane wurde bereits aufgerufen.

Hinweise

Diese Eigenschaft gibt das UserControl zurück, mit dem der benutzerdefinierte Aufgabenbereich erstellt wurde.Weitere Informationen finden Sie unter Benutzerdefinierte Aufgabenbereiche.

Beispiele

Im folgenden Codebeispiel wird die Control-Eigenschaft verwendet, um die Größe von UserControl-im Aufgabenbereich des Ereignishandlers für das DockPositionChanged-Ereignis zu ändern.Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels zu CustomTaskPane.

Private Sub myCustomTaskPane_DockPositionChanged(ByVal sender As Object, _
    ByVal e As EventArgs) Handles myCustomTaskPane.DockPositionChanged

    Dim taskPane As Microsoft.Office.Tools.CustomTaskPane = _
        TryCast(sender, Microsoft.Office.Tools.CustomTaskPane)

    If taskPane IsNot Nothing Then

        ' Adjust sizes of user control and flow panel to fit current task pane size.
        Dim userControl As MyUserControl = TryCast(taskPane.Control, MyUserControl)
        Dim paneSize As System.Drawing.Size = _
            New System.Drawing.Size(taskPane.Width, taskPane.Height)
        userControl.Size = paneSize
        userControl.FlowPanel.Size = paneSize

        ' Adjust flow direction of controls on the task pane.
        If taskPane.DockPosition = _
            Office.MsoCTPDockPosition.msoCTPDockPositionTop Or _
            taskPane.DockPosition = _
            Office.MsoCTPDockPosition.msoCTPDockPositionBottom Then

            userControl.FlowPanel.FlowDirection = _
                System.Windows.Forms.FlowDirection.LeftToRight
        Else
            userControl.FlowPanel.FlowDirection = _
                System.Windows.Forms.FlowDirection.TopDown
        End If
    End If
End Sub
private void myCustomTaskPane_DockPositionChanged(object sender, EventArgs e)
{
    Microsoft.Office.Tools.CustomTaskPane taskPane =
        sender as Microsoft.Office.Tools.CustomTaskPane;

    if (taskPane != null)
    {
        // Adjust sizes of user control and flow panel to fit current task pane size.
        MyUserControl userControl = taskPane.Control as MyUserControl;
        System.Drawing.Size paneSize = new System.Drawing.Size(taskPane.Width, taskPane.Height);
        userControl.Size = paneSize;
        userControl.FlowPanel.Size = paneSize;

        // Adjust flow direction of controls on the task pane.
        if (taskPane.DockPosition == 
            Office.MsoCTPDockPosition.msoCTPDockPositionTop ||
            taskPane.DockPosition ==
            Office.MsoCTPDockPosition.msoCTPDockPositionBottom)
        {
            userControl.FlowPanel.FlowDirection =
                System.Windows.Forms.FlowDirection.LeftToRight;
        }
        else
        {
            userControl.FlowPanel.FlowDirection =
                System.Windows.Forms.FlowDirection.TopDown;
        }
    }
}

.NET Framework-Sicherheit

Siehe auch

Referenz

CustomTaskPane Schnittstelle

Microsoft.Office.Tools-Namespace