Partager via


Button.Placement Property

Gets or sets an object that indicates the way the Button is attached to the cells below it.

Namespace:  Microsoft.Office.Tools.Excel.Controls
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

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

Property Value

Type: System.Object

One of the following XlPlacement values:

Examples

The following code example adds two Button controls that have different run-time behavior to a worksheet. The first button covers the range of cells B2 through C3. When the user resizes a column or row in this range at run time, the first button will resize to adjust to the changes. The second button covers the range of cells B5 through C6, and the Placement property of this button is set to xlFreeFloating. When the user resizes a column or row in this range at run time, the second button will not change size.

This example is for a document-level customization.

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 Security

See Also

Reference

Button Class

Microsoft.Office.Tools.Excel.Controls Namespace