Button.Select Method (Object)
Selects the Button.
Namespace: Microsoft.Office.Tools.Excel.Controls
Assembly: Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)
Syntax
'Declaration
Public Function Select ( _
Replace As Object _
) As Object
public Object Select(
Object Replace
)
Parameters
- Replace
Type: System.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.
Return Value
Type: System.Object
In Excel 2010, this method returns a null reference (Nothing in Visual Basic); otherwise this method returns true.
Remarks
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.
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 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
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);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.