Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Determines whether the specified control is a member of the ControlCollection instance.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
Syntax
'Declaration
Function Contains ( _
control As Object _
) As Boolean
bool Contains(
Object control
)
Parameters
- control
Type: System.Object
The control that you want to search for in the ControlCollection instance.
Return Value
Type: System.Boolean
true if the control was found in the collection; otherwise, false.
Examples
The following code example adds a Button control to the top of the worksheet, and then displays the index of the button in a message box.
Private Sub ExcelControlIndexOf()
Dim Button1 As Microsoft.Office.Tools.Excel. _
Controls.Button = Me.Controls.AddButton( _
0, 0, 56.25, 17.25, "Button1")
Button1.Text = "OK"
If Me.Controls.Contains(Button1) Then
MessageBox.Show("The index of Button1 is " _
& Controls.IndexOf(Button1))
End If
End Sub
private void ExcelControlIndexOf()
{
Microsoft.Office.Tools.Excel.Controls.Button button1 =
this.Controls.AddButton(0, 0, 56.25, 17.25,
"button1");
button1.Text = "OK";
if (this.Controls.Contains(button1))
{
MessageBox.Show("The index of button1 is " +
Controls.IndexOf(button1));
}
}
.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.