Button.BottomRightCell 属性

获取一个 Range 对象,该对象表示位于 Button 右下角下面的单元格。

命名空间:  Microsoft.Office.Tools.Excel.Controls
程序集:  Microsoft.Office.Tools.Excel.v4.0.Utilities(在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

语法

声明
Public ReadOnly Property BottomRightCell As Range
    Get
public Range BottomRightCell { get; }

属性值

类型:Microsoft.Office.Interop.Excel.Range
一个 Range 对象,表示位于 Button 右下角下面的单元格。

备注

返回的单元格取决于该控件重叠的单元格数以及 Placement 属性的设置。

示例

下面的代码示例使用 TopLeftCell 和 BottomRightCell 属性获取某 Button 控件的左上角和右下角的单元格。 该按钮的 Click 事件处理程序将左上角和右下角的单元格的边框涂成红色。

此示例针对的是文档级自定义项。

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
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);
}

.NET Framework 安全性

请参见

参考

Button 类

Microsoft.Office.Tools.Excel.Controls 命名空间