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

Button.Locked 屬性

 

取得或設定值,以指出當工作表設有保護時,是否可以在設計階段修改 Button

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

[BrowsableAttribute(false)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
public bool Locked { get; set; }

屬性值

Type: System.Boolean

當工作表設有保護時,如果無法於設計階段修改 Button,則為 true,否則為 false

A Button can only be locked when the sheet is protected.A locked Button cannot be moved or resized at design time.

The following code example adds two Button controls to the current worksheet and sets the Locked property of one of the buttons to true.The example then protects the worksheet and uses the ToggleFormsDesign method to place Microsoft Office Excel into design mode.At this point, the unlocked button can be moved and resized, but the locked button cannot be moved or resized.

This example is for a document-level customization.

private void TestLockedControl()
{
    Microsoft.Office.Tools.Excel.Controls.Button lockedButton =
            this.Controls.AddButton(this.Range["B2", "C3"],
            "lockedButton");
    lockedButton.Locked = true;
    lockedButton.Text = "Locked button";

    Microsoft.Office.Tools.Excel.Controls.Button unlockedButton =
            this.Controls.AddButton(this.Range["B6", "C7"],
            "unlockedButton");
    unlockedButton.Locked = false;
    unlockedButton.Text = "Unlocked button";

    this.Protect();
    Globals.ThisWorkbook.ToggleFormsDesign();
}
回到頁首
顯示: