次の方法で共有


Button.Border プロパティ

Button の境界を表す Border を取得します。

名前空間:  Microsoft.Office.Tools.Excel.Controls
アセンブリ:  Microsoft.Office.Tools.Excel.v4.0.Utilities (Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 内)

構文

'宣言
Public ReadOnly Property Border As Border
public Border Border { get; }

プロパティ値

型 : Microsoft.Office.Interop.Excel.Border
Button の境界を表す Border です。

次のコード例では、Button コントロールをワークシートに追加し、Border プロパティを使ってセルの境界線を緑色にします。 ボタンの Click イベント ハンドラーは、Visible プロパティを使ってボタンを非表示にし、ボタンを表示するか非表示のままにするかをユーザーが選択できるプロンプトを表示します。

この例は、ドキュメント レベルのカスタマイズ用に作成されています。

Private Sub AlterControlAppearance()
    Dim HideButton As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B2", "C3"), "HideButton")

    HideButton.Text = "Click to hide"
    HideButton.Border.Color = ColorTranslator.ToOle(Color.Green)
    AddHandler HideButton.Click, AddressOf hideButton_Click
End Sub

Private Sub HideButton_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.Visible = False

    ' Allow the user to make the button visible.
    If DialogResult.Yes = MessageBox.Show( _
        "This sheet contains a hidden control." & _
        " Make it visible?", "Example", MessageBoxButtons.YesNo) Then
        ClickedButton.Visible = True
    End If
End Sub
private void AlterControlAppearance()
{
    Microsoft.Office.Tools.Excel.Controls.Button hideButton =
        this.Controls.AddButton(this.Range["B2", "C3"],
        "hideButton");

    hideButton.Text = "Click to hide";
    hideButton.Border.Color = ColorTranslator.ToOle(Color.Green);
    hideButton.Click += new EventHandler(hideButton_Click);
}

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

    // Allow the user to make the button visible.
    if (DialogResult.Yes ==
        MessageBox.Show("This sheet contains a hidden control." +
        " Make it visible?", "Example", MessageBoxButtons.YesNo))
    {
        clickedButton.Visible = true;
    }
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

Button クラス

Microsoft.Office.Tools.Excel.Controls 名前空間