CustomTaskPane.DockPositionChanged Event (2007 System)

Occurs when the user changes the dock position of the custom task pane, or when code changes the value of the DockPosition property.

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

Syntax

'Declaration
Public Event DockPositionChanged As EventHandler
'Usage
Dim instance As CustomTaskPane 
Dim handler As EventHandler 

AddHandler instance.DockPositionChanged, handler
public event EventHandler DockPositionChanged
public:
 event EventHandler^ DockPositionChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
JScript does not support events.

Examples

The following code example demonstrates an event handler for the DockPositionChanged event. This event handler changes the horizontal or vertical arrangement of controls on the task pane by modifying the FlowDirection property of a FlowLayoutPanel on the task pane. This code example assumes that the task pane contains a UserControl named MyUserControl, and the UserControl contains a FlowLayoutPanel named FlowPanel. This example is part of a larger example provided for the CustomTaskPane class.

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 Security

See Also

Reference

CustomTaskPane Class

CustomTaskPane Members

Microsoft.Office.Tools Namespace