Button.BottomRightCell Property

Definition

Gets a Range object that represents the cell that lies under the lower-right corner of the Button.

public:
 property Microsoft::Office::Interop::Excel::Range ^ BottomRightCell { Microsoft::Office::Interop::Excel::Range ^ get(); };
public Microsoft.Office.Interop.Excel.Range BottomRightCell { get; }
member this.BottomRightCell : Microsoft.Office.Interop.Excel.Range
Public ReadOnly Property BottomRightCell As Range

Property Value

A Range object that represents the cell that lies under the lower-right corner of the Button.

Examples

The following code example uses the TopLeftCell and BottomRightCell properties to get the top left and bottom right cells in relation to a Button control. The Click event handler of the button colors the borders of the top left and bottom right cell red.

This example is for a document-level customization.

private void MarkCornerCells()
{
    Microsoft.Office.Tools.Excel.Controls.Button button1 =
        this.Controls.AddButton(65, 45, 100, 25,
        "button1");
    button1.Text = "Click to highlight corners.";
    button1.Click += new EventHandler(button1_Click);
}

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

    clickedButton.BottomRightCell.Borders.Color = 
        ColorTranslator.ToOle(Color.Red);
    clickedButton.TopLeftCell.Borders.Color =
        ColorTranslator.ToOle(Color.Red);
}
Private Sub MarkCornerCells()
    Dim CornerButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(65, 45, 100, 25, "CornerButton")
    CornerButton.Text = "Click to highlight corners."
    AddHandler CornerButton.Click, AddressOf CornerButton_Click
End Sub

Private Sub CornerButton_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)
    ClickedButton.BottomRightCell.Borders.Color = _
        ColorTranslator.ToOle(Color.Red)
    ClickedButton.TopLeftCell.Borders.Color = _
        ColorTranslator.ToOle(Color.Red)
End Sub

Remarks

The cell returned depends on how many cells the control overlaps and the setting of the Placement property.

Applies to