Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Manage Control Layout on Actions Panes

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

Microsoft Office version

  • 2007 Microsoft Office system

  • Microsoft Office 2003

For more information, see Features Available by Application and Project Type.

An actions pane is docked to the right of a document or worksheet by default; however, it can be docked to the left, top, or bottom. If you are using multiple user controls, you can write code to properly stack the user controls on the actions pane. For more information, see Actions Pane Overview.

The stack order of the controls depends on whether the actions pane is docked vertically or horizontally.

NoteNote:

If the user resizes the actions pane at run time, you can set the controls to resize with the actions pane. You can use the Anchor property of a Windows Forms control to anchor controls to the actions pane. For more information, see How to: Anchor Controls on Windows Forms.

You can use the sample code in Walkthrough: Changing the Actions Pane According to User Context to create the multiple actions pane controls needed for the following procedure.

NoteNote:

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To set the stack order of the actions pane controls

  1. Open a document-level project for Microsoft Office Word that includes an actions pane with multiple user controls or nested actions pane controls. For more information, see How to: Add an Actions Pane to Word Documents.

  2. Right-click ThisDocument.cs or ThisDocument.vb in Solution Explorer and then click View Code.

  3. In the OrientationChanged event handler of the actions pane, check if the orientation of the actions pane is horizontal.

    private void ActionsPane_OrientationChanged(object sender, EventArgs e)
    {
        if (ActionsPane.Orientation == Orientation.Horizontal)
        {
    
  4. If the orientation is horizontal, stack the action pane controls from the left; otherwise, stack them from the top.

            this.ActionsPane.StackOrder = Microsoft.Office.Tools.StackStyle.FromLeft;
        }
        else
        {
            this.ActionsPane.StackOrder = Microsoft.Office.Tools.StackStyle.FromTop;
        }
    }
    
  5. In C#, you must add an event handler for the ActionsPane to the Startup event handler. For information about creating event handlers, see How to: Create Event Handlers in Visual Studio Tools for Office.

    private void ThisDocument_Startup(object sender, System.EventArgs e)
    {
        this.ActionsPane.OrientationChanged += new EventHandler(ActionsPane_OrientationChanged);
    }
    
  6. Run the project and verify that the actions pane controls are stacked left to right when the actions pane is docked at the top of the document, and the controls are stacked from top to bottom when the actions pane is docked at the right side of the document.

private void ThisDocument_Startup(object sender, System.EventArgs e)
{
    this.ActionsPane.OrientationChanged += new EventHandler(ActionsPane_OrientationChanged);
}

private void ActionsPane_OrientationChanged(object sender, EventArgs e)
{
    if (ActionsPane.Orientation == Orientation.Horizontal)
    {
        this.ActionsPane.StackOrder = Microsoft.Office.Tools.StackStyle.FromLeft;
    }
    else
    {
        this.ActionsPane.StackOrder = Microsoft.Office.Tools.StackStyle.FromTop;
    }
}

This example requires:

  • A Word document-level project with an actions pane that contains multiple user controls or nested actions pane controls.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft