Compartir a través de


CustomTaskPane.Control (Propiedad)

Obtiene el UserControl que proporciona la interfaz de usuario del panel de tareas personalizado.

Espacio de nombres:  Microsoft.Office.Tools
Ensamblado:  Microsoft.Office.Tools.Common (en Microsoft.Office.Tools.Common.dll)

Sintaxis

'Declaración
ReadOnly Property Control As UserControl
UserControl Control { get; }

Valor de propiedad

Tipo: System.Windows.Forms.UserControl
UserControl que proporciona la interfaz de usuario del panel de tareas personalizado.

Excepciones

Excepción Condición
ObjectDisposedException

Ya se ha llamado al método Dispose de CustomTaskPane.

Comentarios

Esta propiedad devuelve el UserControl utilizado para crear el panel de tareas personalizado.Para obtener más información, vea Paneles de tareas personalizados.

Ejemplos

En el ejemplo de código siguiente se utiliza la propiedad Control para modificar el tamaño de UserControl en el panel de tareas en el controlador del evento DockPositionChanged.Este ejemplo de código forma parte de un ejemplo más extenso proporcionado para 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;
        }
    }
}

Seguridad de .NET Framework

Vea también

Referencia

CustomTaskPane Interfaz

Microsoft.Office.Tools (Espacio de nombres)