Share via


Button.Placement 屬性

取得或設定物件,表示將 Button 附加至其下方儲存格的方式。

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

語法

'宣告
Public Property Placement As Object
public Object Placement { get; set; }

屬性值

型別:System.Object

下列其中一個 XlPlacement 值:

範例

下列程式碼範例會將執行階段行為不同的兩個 Button 控制項加入至工作表。 第一個按鈕的位置涵蓋了儲存格 B2 到 C3 的範圍。 如果使用者在執行階段調整這個範圍內任何欄或列的大小,就會調整第一個按鈕的大小以配合所做的變更。 第二個按鈕的位置則涵蓋了儲存格 B5 到 C6 的範圍,而且這個按鈕的 Placement 屬性會設定為 xlFreeFloating。 如果使用者在執行階段調整這個範圍內任何欄或列的大小,第二個按鈕的大小不會變更。

這是示範文件層級自訂的範例。

Private Sub ComparePlacementBehavior()

    Dim CellButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B2", "C3"), "CellButton")
    CellButton.Text = "Resizes with cells"

    Dim FixedButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B5", "C6"), "FixedButton")
    FixedButton.Text = "Does not resize"
    FixedButton.Placement = Excel.XlPlacement.xlFreeFloating
End Sub
private void ComparePlacementBehavior()
{
    Microsoft.Office.Tools.Excel.Controls.Button cellButton =
        this.Controls.AddButton(this.Range["B2", "C3"],
        "cellButton");
    cellButton.Text = "Resizes with cells";

    Microsoft.Office.Tools.Excel.Controls.Button fixedButton =
        this.Controls.AddButton(this.Range["B5", "C6"],
        "fixedButton");
    fixedButton.Text = "Does not resize";
    fixedButton.Placement = Excel.XlPlacement.xlFreeFloating;
}

.NET Framework 安全性

請參閱

參考

Button 類別

Microsoft.Office.Tools.Excel.Controls 命名空間