ControlCollection Interface
TOC
Collapse the table of content
Expand the table of content

ControlCollection Interface

 

Represents a collection of managed controls on an Excel worksheet in an Office solution.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

[GuidAttribute("0B027FC3-018C-4917-AE33-A09E0A30A661")]
public interface ControlCollection : IEnumerable

NameDescription
System_CAPS_pubpropertyCount

Gets the number of controls in the ControlCollection.

System_CAPS_pubpropertyItem[Int32]

Gets the control at the specified index.

System_CAPS_pubpropertyItem[String]

Gets the control with the specified name.

NameDescription
System_CAPS_pubmethodAddChart(Double, Double, Double, Double, String)

Adds a new Chart control to the worksheet in the specified size and location.

System_CAPS_pubmethodAddChart(Range, String)

Adds a new Chart control to the worksheet at the range specified.

System_CAPS_pubmethodAddControl(Control, Double, Double, Double, Double, String)

Adds the specified Control to the ControlCollection at the location and size specified.

System_CAPS_pubmethodAddControl(Control, Range, String)

Adds the specified Control to the ControlCollection at the specified range.

System_CAPS_pubmethodAddListObject(ListObject)

Adds a Visual Studio Microsoft.Office.Tools.Excel.ListObject to the control collection based on the specified native Microsoft.Office.Interop.Excel.ListObject.

System_CAPS_pubmethodAddListObject(Range, String)

Adds a new ListObject control to the worksheet at the range specified.

System_CAPS_pubmethodAddNamedRange(Range, String)

Adds a new NamedRange control to the worksheet at the range specified.

System_CAPS_pubmethodContains(Object)

Determines whether the specified control is a member of the ControlCollection instance.

System_CAPS_pubmethodContains(String)

Determines whether a control with the specified name is a member of the ControlCollection instance.

System_CAPS_pubmethodGetEnumerator()

(Inherited from IEnumerable.)

System_CAPS_pubmethodIndexOf(Object)

Searches for the specified control and returns the zero-based index of the first occurrence in the ControlCollection instance.

System_CAPS_pubmethodIndexOf(String)

Searches for the first occurrence of a control with the specified name in the ControlCollection instance.

System_CAPS_pubmethodRemove(Object)

Removes the specified control from the ControlCollection instance.

System_CAPS_pubmethodRemove(String)

Removes the control with the specified name from the ControlCollection instance.

System_CAPS_pubmethodRemoveAt(Int32)

Removes the control at the specified index in the ControlCollection instance.

Use the methods and properties of the ControlCollection interface to manage controls on an Excel worksheet. For more information, see Adding Controls to Office Documents at Run Time.

You cannot create an instance of this interface in your code, because it does not have any public constructors. To get an instance of this interface in a document-level project, use the Controls property of one of the Sheetn classes in your project. To get an instance of this interface 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 VSTO 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 Microsoft.Office.Tools.Excel.ListObject, use the AddListObject 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.

System_CAPS_noteNote

This interface is implemented by the Visual Studio Tools for Office runtime. It is not intended to be implemented in your code. For more information, see Visual Studio Tools for Office Runtime Overview.

This documentation describes the version of this type that is used in Office projects that target the .NET Framework 4 or later. In projects that target the .NET Framework 3.5, this type might have different members and the code examples provided for this type might not work. For documentation about this type in projects that target the .NET Framework 3.5, see the following reference section in the Visual Studio 2008 documentation: http://go.microsoft.com/fwlink/?LinkId=160658.

Return to top
Show:
© 2016 Microsoft