Button.Select(Object) Method

Definition

Selects the Button.

public:
 System::Object ^ Select(System::Object ^ Replace);
public object Select (object Replace);
override this.Select : obj -> obj
Public Function Select (Replace As Object) As Object

Parameters

Replace
Object

true to replace the current selection with the Button; false to extend the current selection to include any previously selected objects and the Button.

Returns

This method returns a null reference (Nothing in Visual Basic); otherwise this method returns true.

Examples

The following code example adds two Button controls to a worksheet and then programmatically selects both of the buttons by using the Select method. The first call to Select passes in true for the value of the Replace parameter to make sure that the first button is the only selection on the worksheet. The second call to Select passes in false so that the second button is selected in addition to the first button.

This example is for a document-level customization.

private void SelectControl()
{
    Microsoft.Office.Tools.Excel.Controls.Button selectButton1 =
        this.Controls.AddButton(this.Range["B2", "C3"],
        "selectButton1");
    selectButton1.Text = "Button 1";

    Microsoft.Office.Tools.Excel.Controls.Button selectButton2 =
        this.Controls.AddButton(this.Range["B4","C5"],
        "selectButton2");
    selectButton2.Text = "Button 2";

    selectButton1.Select(true);
    selectButton2.Select(false);
}
Private Sub SelectControl()
    Dim SelectButton1 As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B2", "C3"), "SelectButton1")
    SelectButton1.Text = "Button 1"

    Dim SelectButton2 As Microsoft.Office.Tools.Excel.Controls.Button = _
        Me.Controls.AddButton(Me.Range("B4", "C5"), "SelectButton2")
    SelectButton2.Text = "Button 2"

    SelectButton1.Select(True)
    SelectButton2.Select(False)
End Sub

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to