获取或设置一个对象,该对象指示 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
    Get
    Set
public Object Placement { get; set; }
属性值
以下 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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。