本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

Button.SendToBack 方法 ()

 

Button 移到疊置順序的最後面。

命名空間:   Microsoft.Office.Tools.Excel.Controls
組件:  Microsoft.Office.Tools.Excel.v4.0.Utilities (在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

public object SendToBack()

傳回值

Type: System.Object

這個方法會傳回 Null 參考 (在 Visual Basic 中為 Nothing),否則這個方法會傳回 true

This method sets the z-order of the Button to the first index in the OLEObjects collection; the numbering of the z-order is the opposite of the numbering of the index in the OLEObjects collection. The higher the index in the OLEObjects collection, the lower the z-order of the Button.

The following code example uses the BringToFront and SendToBack methods to set the z-order of three Button controls on a worksheet. If the button currently at the front of the z-order is clicked, then the button is moved to the back of the collection by calling SendToBack. Otherwise, the button is moved to the front of the collection by calling BringToFront. Note that the z-order of the three buttons initially range from 2 to 4. The Runtime Storage Control on the worksheet initially has the z-order position of 1.

This example is for a document-level customization.

private void ToggleZOrder()
{
    Microsoft.Office.Tools.Excel.Controls.Button button1 =
        this.Controls.AddButton(this.Range["A1", "B2"],
        "button1");
    button1.BackColor = Color.Blue;

    Microsoft.Office.Tools.Excel.Controls.Button button2 =
        this.Controls.AddButton(this.Range["B2", "C3"],
        "button2");
    button2.BackColor = Color.Red;

    Microsoft.Office.Tools.Excel.Controls.Button button3 =
        this.Controls.AddButton(this.Range["C3", "D4"],
        "button3");
    button3.BackColor = Color.Green;

    button1.Click += new EventHandler(zOrderButton_Click);
    button2.Click += new EventHandler(zOrderButton_Click);
    button3.Click += new EventHandler(zOrderButton_Click);
}

void zOrderButton_Click(object sender, EventArgs e)
{
    Microsoft.Office.Tools.Excel.Controls.Button clickedButton =
        (Microsoft.Office.Tools.Excel.Controls.Button)sender;

    if (clickedButton.ZOrder == 4)
    {
        clickedButton.SendToBack();
    }
    else
    {
        clickedButton.BringToFront();
    }
}
回到頁首
顯示: