Button.Placement 屬性

定義

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

public:
 property System::Object ^ Placement { System::Object ^ get(); void set(System::Object ^ value); };
public object Placement { get; set; }
member this.Placement : obj with get, set
Public Property Placement As Object

屬性值

下列 XlPlacement 其中一個值: xlFreeFloatingxlMove. xlMoveAndSize.

範例

下列程式代碼範例會將具有不同運行時間行為的兩 Button 個控件新增至工作表。 第一個按鈕涵蓋單元格 B2 到 C3 的範圍。 當使用者在運行時間調整此範圍中的數據行或數據列大小時,第一個按鈕會重設大小以調整變更。 第二個按鈕涵蓋儲存格 B5 到 C6 的範圍,而 Placement 此按鈕的 屬性會設定為 xlFreeFloating。 當使用者在運行時間調整此範圍中的數據行或數據列大小時,第二個按鈕將不會變更大小。

此範例適用於檔層級自定義。

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;
}
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

適用於