Leer en inglés

Compartir a través de


Button.Right Property

Definition

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

C#
public double Right { get; }

Property Value

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

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.

C#
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());
}

Remarks

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

The Microsoft.Office.Tools.Excel.Controls.Button.Right property uses points, whereas System.Windows.Forms.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.

Applies to

Producto Versiones
Visual Studio Tools for Office 2017, 2019, 2022