次の方法で共有


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
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 名前空間