共用方式為


Button.Right 屬性

定義

取得 Button 的右邊緣和工作表的左邊緣之間的距離 (以點為單位)。

public double Right { get; }

屬性值

Button 的右邊緣和工作表的左邊緣之間的距離 (以點為單位)。

範例

下列程式碼範例會在 Button 儲存格 B2 上新增 控制項。 Click按鈕的事件處理常式會顯示按鈕之 RightBottom 屬性的目前值。 當資料行 B 或資料列 2 在執行時間調整大小時,這些值會根據資料行或資料列的新大小而變更。

此範例適用于檔層級自訂。

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

備註

屬性的值 Right 等於屬性值和屬性值的總 LeftWidth

屬性 Microsoft.Office.Tools.Excel.Controls.Button.Right 使用點,而 System.Windows.Forms.Control.Right 屬性則使用圖元。

將值設定為負數或大於 12288 的數位不會擲回例外狀況,但會導致控制項在 0 到 12288 之間設定。

適用於