ControlCollection Class (2007 System)
Represents a collection of managed controls on an Excel worksheet that is part of a Visual Studio Tools for Office solution.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public NotInheritable Class ControlCollection _
Inherits CollectionBase _
Implements IDisposable
'Usage
Dim instance As ControlCollection
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public sealed class ControlCollection : CollectionBase,
IDisposable
[PermissionSetAttribute(SecurityAction::Demand, Name = L"FullTrust")]
public ref class ControlCollection sealed : public CollectionBase,
IDisposable
public final class ControlCollection extends CollectionBase implements IDisposable
Remarks
Use the methods and properties of the ControlCollection class to manage controls on an Excel worksheet. For more information, see Adding Controls to Office Documents at Run Time.
You cannot instantiate this class in your code, because it does not have any public constructors. To get an instance of this class in a document-level project, use the Controls property of one of the Sheetn class in your project. To get an instance of this class in a document-level project, use the Controls property of a Worksheet host item that you create programmatically at run time. For more information, see Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time.
The following table shows how to use ControlCollection members to perform some common tasks related to controls on documents.
Task |
Action |
---|---|
Add a control to the worksheet. |
Use one of the Add<control> methods. For example, to add a Button, use the AddButton method. |
Remove a control from the worksheet. |
Use the Remove method. |
Determine whether a control is in the collection. |
Pass the control or its name to the Contains method. |
Get the index of a control in the collection. |
Pass the control or its name to the IndexOf method. |
Get a control from the collection. |
Pass the index or name of the control to the Item property. |
Inheritance Hierarchy
System.Object
System.Collections.CollectionBase
Microsoft.Office.Tools.Excel.ControlCollection
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.