Button.Right 属性

获取 Button 的右边缘与工作表的左边缘之间的距离(以磅为单位)。

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

语法

声明
Public ReadOnly Property Right As Double
    Get
public double Right { get; }

属性值

类型:System.Double
Button 的右边缘与工作表的左边缘之间的距离(以磅为单位)。

备注

Right 属性的值等于 Left 属性值与 Width 属性值之和。

Button.Right 属性使用磅值,而 Control.Right 属性使用像素值。

将该值设置为负数或大于 12288 的数不会引发异常,但会导致将控件设置为 0 到 12288 之间的数。

示例

下面的代码示例在单元格 B2 上添加一个 Button 控件。 该按钮的 Click 事件处理程序显示按钮的 Right 和 Bottom 属性的当前值。 如果在运行时第 B 列或第 2 行的大小进行了调整,这些属性值将根据列或行的新大小而改变。

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

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 安全性

请参见

参考

Button 类

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