Share via


CustomTaskPane.Width Property (2007 System)

Gets or sets the width of the custom task pane, in points.

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

Syntax

'Declaration
Public Property Width As Integer
'Usage
Dim instance As CustomTaskPane 
Dim value As Integer 

value = instance.Width

instance.Width = value
public int Width { get; set; }
public:
property int Width {
    int get ();
    void set (int value);
}
public function get Width () : int 
public function set Width (value : int)

Property Value

Type: System.Int32
The width of the custom task pane, in points.

Exceptions

Exception Condition
COMException

The value of the DockPosition property is Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionTop or Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionBottom when you try to set the Width property.

-or-

You try to set the Width property in the event handler for the DockPositionChanged or VisibleChanged event.

ObjectDisposedException

The Dispose method of the CustomTaskPane has already been called.

Remarks

Do not use the Width property if the custom task pane is docked to the top or the bottom of the document window. If the DockPosition property is Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionTop or Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionBottom, the Width property returns 0 and throws a COMException if you try to set it.

The maximum width depends on the dock position. When the custom task pane is docked to the left or right of the document window, the maximum width is approximately half the width of the screen. When the custom task pane is floating, there is no maximum width.

The minimum width depends on several factors, and can change in future releases of Microsoft Office. If you try to set the Width property to a value that is less than the minimum width, the application will automatically reassign the Width property to the minimum width.

Examples

The following code example creates a custom task pane that has a different default width when it displays in front of the active application window, and when it is docked to the left or right side of the window. This code example is part of a larger example provided for the CustomTaskPane class.

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 Security

See Also

Reference

CustomTaskPane Class

CustomTaskPane Members

Microsoft.Office.Tools Namespace

Change History

Date

History

Reason

February 2009

Added information about maximum and minimum width.

Customer feedback.