ActionsPane.StackOrder (Propiedad)

Obtiene o establece un valor que indica la dirección en la que los controles se apilan en el panel de acciones.

Espacio de nombres:  Microsoft.Office.Tools
Ensamblado:  Microsoft.Office.Tools.Common (en Microsoft.Office.Tools.Common.dll)

Sintaxis

'Declaración
Property StackOrder As StackStyle
    Get
    Set
StackStyle StackOrder { get; set; }

Valor de propiedad

Tipo: Microsoft.Office.Tools.StackStyle
Un valor que indica la dirección en la que los controles se apilan en el recuadro de acciones.

Comentarios

El orden de la pila depende de la orientación del panel de acciones. Si la orientación del recuadro de acciones se establece en horizontal, puede que desee establecer el orden de la pila en los valores FromLeft o FromRight de la enumeración StackStyle. Si la orientación del recuadro de acciones se establece en vertical, puede que desee establecer el orden de la pila en los valores FromTop o FromBottom de la enumeración StackStyle.

Cambia a la orientación del panel de acciones que se comunican a través del evento OrientationChanged.

Ejemplos

En el ejemplo de código siguiente se muestra un panel de acciones que automáticamente ajusta la alineación de su contenido. Cuando el usuario cambia la orientación de las acciones moviendo el panel de acciones a una parte distinta de la ventana de la aplicación o el usuario hace clic en un control Button del panel de acciones, la propiedad Orientation se usa para determinar el nuevo valor de la propiedad StackOrder. Para ejecutar este código, llame al método InitActionsPane desde el controlador de eventos ThisWorkbook_Startup de un proyecto de Microsoft Office Excel.

Private Sub InitActionsPane()
    With Globals.ThisWorkbook.ActionsPane
        .Clear()
        .Visible = True
        .AutoRecover = True
    End With

    AddHandler Globals.ThisWorkbook.ActionsPane.OrientationChanged, _
        AddressOf ActionsPane_OrientationChanged
    ResetStackOrder()

    ' Create the button that will update the stack order.
    Dim button1 As New Button()
    button1.Text = "Change stack order"
    AddHandler button1.Click, AddressOf button1_Click

    ' Create two more buttons that do nothing.
    Dim button2 As New Button()
    button2.Text = "Button 2"
    Dim button3 As New Button()
    button3.Text = "Button 3"

    Globals.ThisWorkbook.ActionsPane.Controls.AddRange(New Control() _
        {button1, button2, button3})
End Sub

' Switch the stack order according to the current orientation.
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)

    If Globals.ThisWorkbook.ActionsPane.Orientation = _
        Orientation.Horizontal Then

        If Globals.ThisWorkbook.ActionsPane.StackOrder = _
            Microsoft.Office.Tools.StackStyle.FromLeft Then
            Globals.ThisWorkbook.ActionsPane.StackOrder = _
                Microsoft.Office.Tools.StackStyle.FromRight
        Else
            Globals.ThisWorkbook.ActionsPane.StackOrder = _
                Microsoft.Office.Tools.StackStyle.FromLeft
        End If
    Else
        If Globals.ThisWorkbook.ActionsPane.StackOrder = _
            Microsoft.Office.Tools.StackStyle.FromTop Then
            Globals.ThisWorkbook.ActionsPane.StackOrder = _
                Microsoft.Office.Tools.StackStyle.FromBottom
        Else
            Globals.ThisWorkbook.ActionsPane.StackOrder = _
                Microsoft.Office.Tools.StackStyle.FromTop
        End If
    End If
End Sub

Private Sub ActionsPane_OrientationChanged(ByVal sender As Object, _
    ByVal e As EventArgs)
    ResetStackOrder()
End Sub

' Readjust the stack order so that it matches the current orientation.
Sub ResetStackOrder()
    If Globals.ThisWorkbook.ActionsPane.Orientation = _
        Orientation.Horizontal Then

        If (Globals.ThisWorkbook.ActionsPane.StackOrder = _
        Microsoft.Office.Tools.StackStyle.FromTop Or _
        Globals.ThisWorkbook.ActionsPane.StackOrder = _
        Microsoft.Office.Tools.StackStyle.FromBottom) Then
            Globals.ThisWorkbook.ActionsPane.StackOrder = _
                Microsoft.Office.Tools.StackStyle.FromLeft
        End If
    End If

    If Globals.ThisWorkbook.ActionsPane.Orientation = _
        Orientation.Vertical Then

        If (Globals.ThisWorkbook.ActionsPane.StackOrder = _
        Microsoft.Office.Tools.StackStyle.FromLeft Or _
        Globals.ThisWorkbook.ActionsPane.StackOrder = _
        Microsoft.Office.Tools.StackStyle.FromRight) Then
            Globals.ThisWorkbook.ActionsPane.StackOrder = _
                Microsoft.Office.Tools.StackStyle.FromTop
        End If
    End If
End Sub
private void InitActionsPane()
{
    Globals.ThisWorkbook.ActionsPane.Clear();
    Globals.ThisWorkbook.ActionsPane.Visible = true;
    Globals.ThisWorkbook.ActionsPane.AutoRecover = true;
    Globals.ThisWorkbook.ActionsPane.OrientationChanged +=
        new EventHandler(ActionsPane_OrientationChanged);
    ResetStackOrder();

    // Create the button that will update the stack order.
    Button button1 = new Button();
    button1.Text = "Change stack order";
    button1.Click += new EventHandler(button1_Click);

    // Create two more buttons that do nothing.
    Button button2 = new Button();
    button2.Text = "Button 2";
    Button button3 = new Button();
    button3.Text = "Button 3";

    Globals.ThisWorkbook.ActionsPane.Controls.AddRange(
        new Control[] { button1, button2, button3 });
}

// Switch the stack order according to the current orientation.
void button1_Click(object sender, EventArgs e)
{
    if (Globals.ThisWorkbook.ActionsPane.Orientation == 
        Orientation.Horizontal)
    {
        if (Globals.ThisWorkbook.ActionsPane.StackOrder == 
            Microsoft.Office.Tools.StackStyle.FromLeft)
        {
            Globals.ThisWorkbook.ActionsPane.StackOrder =
                Microsoft.Office.Tools.StackStyle.FromRight;
        }
        else
        {
            Globals.ThisWorkbook.ActionsPane.StackOrder =
                Microsoft.Office.Tools.StackStyle.FromLeft;
        }
    }
    else
    {
        if (Globals.ThisWorkbook.ActionsPane.StackOrder ==
            Microsoft.Office.Tools.StackStyle.FromTop)
        {
            Globals.ThisWorkbook.ActionsPane.StackOrder =
                Microsoft.Office.Tools.StackStyle.FromBottom;
        }
        else
        {
            Globals.ThisWorkbook.ActionsPane.StackOrder =
                Microsoft.Office.Tools.StackStyle.FromTop;
        }
    }
}

void ActionsPane_OrientationChanged(object sender, EventArgs e)
{
    ResetStackOrder();
}

// Readjust the stack order so that it matches the current orientation.
void ResetStackOrder()
{
    if (Globals.ThisWorkbook.ActionsPane.Orientation == 
        Orientation.Horizontal &&
       (Globals.ThisWorkbook.ActionsPane.StackOrder == 
           Microsoft.Office.Tools.StackStyle.FromTop ||
        Globals.ThisWorkbook.ActionsPane.StackOrder ==
           Microsoft.Office.Tools.StackStyle.FromBottom))
    {
        Globals.ThisWorkbook.ActionsPane.StackOrder =
            Microsoft.Office.Tools.StackStyle.FromLeft;
    }

    if (Globals.ThisWorkbook.ActionsPane.Orientation == 
        Orientation.Vertical &&
       (Globals.ThisWorkbook.ActionsPane.StackOrder ==
           Microsoft.Office.Tools.StackStyle.FromLeft ||
        Globals.ThisWorkbook.ActionsPane.StackOrder ==
           Microsoft.Office.Tools.StackStyle.FromRight))
    {
        Globals.ThisWorkbook.ActionsPane.StackOrder =
            Microsoft.Office.Tools.StackStyle.FromTop;
    }
}

Seguridad de .NET Framework

Vea también

Referencia

ActionsPane Interfaz

Microsoft.Office.Tools (Espacio de nombres)

Otros recursos

Información general sobre recuadros de acciones