CustomTaskPane.Height Property

Definition

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

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

Property Value

The height of the custom task pane, in points.

Exceptions

The value of the DockPosition property is Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight or Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionLeft when you try to set the Height property.-or-You try to set the Height property in the event handler for the DockPositionChanged or VisibleChanged event.

The Microsoft.Office.Tools.CustomTaskPane.Dispose method of the CustomTaskPane has already been called.

Examples

The following code example creates a custom task pane that has a specified height when it displays in front of the active application window. This code example is part of a larger example provided for 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

Remarks

Do not use the Height property if the custom task pane is docked to the left or the right of the document window. If the DockPosition property is Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight or Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionLeft, the Height property returns 0 and throws a COMException if you try to set it.

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

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

Applies to