Compartilhar via


Button.Border Property

Definition

Gets a Border that represents the border of the Button.

public:
 property Microsoft::Office::Interop::Excel::Border ^ Border { Microsoft::Office::Interop::Excel::Border ^ get(); };
public Microsoft.Office.Interop.Excel.Border Border { get; }
member this.Border : Microsoft.Office.Interop.Excel.Border
Public ReadOnly Property Border As Border

Property Value

A Border that represents the border of the Button.

Examples

The following code example adds a Button control to a worksheet and uses the Border property to color the border of the cell green. The Click event handler of the button uses the Visible property to hide the button, and then prompts the user to choose to either unhide the button, or allow it to remain hidden.

This example is for a document-level customization.

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

Applies to