Share via


Button.Right Property

Gets the distance, in points, between the right edge of the Button and the left edge of the worksheet.

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 ReadOnly Property Right As Double
public double Right { get; }

Property Value

Type: System.Double
The distance, in points, between the right edge of the Button and the left edge of the worksheet.

Remarks

The value of the Right property is equal to the sum of the Left property value and the Width property value.

The Button.Right property uses points, whereas Control.Right property uses pixels.

Setting the value to a negative number or a number higher than 12288 does not throw an exception but results in the control being set between 0 and 12288.

Examples

The following code example adds a Button control on cell B2. The Click event handler of the button displays the current values of the Right and Bottom properties of the button. When column B or row 2 is resized at run time, these values change according to the new size of the column or row.

This example is for a document-level customization.

Private Sub DisplayRightAndBottom()
    Dim PointButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B2", "C3"), "PointButton")
    PointButton.Text = "Click to display location" 
    AddHandler PointButton.Click, AddressOf PointButton_Click
End Sub 

Private Sub PointButton_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim ClickedButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        CType(sender, Microsoft.Office.Tools.Excel.Controls.Button)

    MsgBox("Right is: " & ClickedButton.Right.ToString() & _
        "; Bottom is: " & ClickedButton.Bottom.ToString())
End Sub
private void DisplayRightAndBottom()
{
    Microsoft.Office.Tools.Excel.Controls.Button pointButton =
        this.Controls.AddButton(this.Range["B2", "C3"],
        "pointButton");
    pointButton.Text = "Click to display location";
    pointButton.Click += new EventHandler(pointButton_Click);
}

void pointButton_Click(object sender, EventArgs e)
{
    Microsoft.Office.Tools.Excel.Controls.Button clickedButton =
        (Microsoft.Office.Tools.Excel.Controls.Button)sender;

    MessageBox.Show("Right is: " + clickedButton.Right.ToString() +
        "; Bottom is: " + clickedButton.Bottom.ToString());
}

.NET Framework Security

See Also

Reference

Button Class

Microsoft.Office.Tools.Excel.Controls Namespace