CustomTaskPane.Width Propiedad

Definición

Obtiene o establece el ancho del panel de tareas personalizado, en puntos.

public:
 property int Width { int get(); void set(int value); };
public int Width { get; set; }
member this.Width : int with get, set
Public Property Width As Integer

Valor de propiedad

Ancho del panel de tareas personalizado, en puntos.

Excepciones

El valor de la DockPosition propiedad es Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionTop o Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionBottom cuando intenta establecer la Width propiedad.-o-Intenta establecer la Width propiedad en el controlador de eventos para el DockPositionChanged evento o VisibleChanged .

Ya se ha llamado al método Microsoft.Office.Tools.CustomTaskPane.Dispose del objeto CustomTaskPane.

Ejemplos

En el ejemplo de código siguiente se crea un panel de tareas personalizado que tiene un ancho predeterminado diferente cuando se muestra delante de la ventana de aplicación activa y cuando está acoplado a la izquierda o al lado derecho de la ventana. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para CustomTaskPane.

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

Comentarios

No use la Width propiedad si el panel de tareas personalizado está acoplado a la parte superior o inferior de la ventana del documento. Si la DockPosition propiedad es Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionTop o Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionBottom, la Width propiedad devuelve 0 y produce un COMException si intenta establecerla.

El ancho máximo depende de la posición del muelle. Cuando el panel de tareas personalizado se acopla a la izquierda o a la derecha de la ventana del documento, el ancho máximo es aproximadamente la mitad del ancho de la pantalla. Cuando el panel de tareas personalizado está flotante, no hay ancho máximo.

El ancho mínimo depende de varios factores y puede cambiar en futuras versiones de Microsoft Office. Si intenta establecer la Width propiedad en un valor menor que el ancho mínimo, la aplicación reasignará automáticamente la Width propiedad al ancho mínimo.

Se aplica a