Export (0) Print
Expand All

ControlCollection Interface

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

Namespace:  Microsoft.Office.Tools.Excel
Assemblies:   Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

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

The ControlCollection type exposes the following members.

  NameDescription
Public propertyCountGets the number of controls in the ControlCollection.
Public propertyItem[Int32]Gets the control at the specified index.
Public propertyItem[String]Gets the control with the specified name.
Top

  NameDescription
Public method_VtblGap1_5Infrastructure.
Public methodAddChart(Range, String)Adds a new Chart control to the worksheet at the range specified.
Public methodAddChart(Double, Double, Double, Double, String)Adds a new Chart control to the worksheet in the specified size and location.
Public methodAddControl(Control, Range, String)Adds the specified Control to the ControlCollection at the specified range.
Public methodAddControl(Control, Double, Double, Double, Double, String)Adds the specified Control to the ControlCollection at the location and size specified.
Public methodAddListObject(ListObject)Adds a Visual Studio Microsoft.Office.Tools.Excel.ListObject to the control collection based on the specified native Microsoft.Office.Interop.Excel.ListObject.
Public methodAddListObject(Range, String)Adds a new ListObject control to the worksheet at the range specified.
Public methodAddNamedRangeAdds a new NamedRange control to the worksheet at the range specified.
Public methodContains(Object)Determines whether the specified control is a member of the ControlCollection instance.
Public methodContains(String)Determines whether a control with the specified name is a member of the ControlCollection instance.
Public methodGetEnumeratorReturns an enumerator that iterates through a collection. (Inherited from IEnumerable.)
Public methodIndexOf(Object)Searches for the specified control and returns the zero-based index of the first occurrence in the ControlCollection instance.
Public methodIndexOf(String)Searches for the first occurrence of a control with the specified name in the ControlCollection instance.
Public methodRemove(Object)Removes the specified control from the ControlCollection instance.
Public methodRemove(String)Removes the control with the specified name from the ControlCollection instance.
Public methodRemoveAtRemoves the control at the specified index in the ControlCollection instance.
Top

  NameDescription
Public Extension MethodAddButton(Range, String)Overloaded. Adds a new Button control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddButton(Double, Double, Double, Double, String)Overloaded. Adds a new Button control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddCheckBox(Range, String)Overloaded. Adds a new CheckBox control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddCheckBox(Double, Double, Double, Double, String)Overloaded. Adds a new CheckBox control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddCheckedListBox(Range, String)Overloaded. Adds a new CheckedListBox control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddCheckedListBox(Double, Double, Double, Double, String)Overloaded. Adds a new CheckedListBox control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddComboBox(Range, String)Overloaded. Adds a new ComboBox control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddComboBox(Double, Double, Double, Double, String)Overloaded. Adds a new ComboBox control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddDataGridView(Range, String)Overloaded. Adds a new DataGridView control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddDataGridView(Double, Double, Double, Double, String)Overloaded. Adds a new DataGridView control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddDateTimePicker(Range, String)Overloaded. Adds a new DateTimePicker control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddDateTimePicker(Double, Double, Double, Double, String)Overloaded. Adds a new DateTimePicker control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddDomainUpDown(Range, String)Overloaded. Adds a new DomainUpDown control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddDomainUpDown(Double, Double, Double, Double, String)Overloaded. Adds a new DomainUpDown control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddHScrollBar(Range, String)Overloaded. Adds a new HScrollBar control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddHScrollBar(Double, Double, Double, Double, String)Overloaded. Adds a new HScrollBar control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddLabel(Range, String)Overloaded. Adds a new Label control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddLabel(Double, Double, Double, Double, String)Overloaded. Adds a new Label control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddLinkLabel(Range, String)Overloaded. Adds a new LinkLabel control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddLinkLabel(Double, Double, Double, Double, String)Overloaded. Adds a new LinkLabel control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddListBox(Range, String)Overloaded. Adds a new ListBox control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddListBox(Double, Double, Double, Double, String)Overloaded. Adds a new ListBox control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddListView(Range, String)Overloaded. Adds a new ListView control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddListView(Double, Double, Double, Double, String)Overloaded. Adds a new ListView control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddMaskedTextBox(Range, String)Overloaded. Adds a new MaskedTextBox control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddMaskedTextBox(Double, Double, Double, Double, String)Overloaded. Adds a new MaskedTextBox control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddMonthCalendar(Range, String)Overloaded. Adds a new MonthCalendar control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddMonthCalendar(Double, Double, Double, Double, String)Overloaded. Adds a new MonthCalendar control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddNumericUpDown(Range, String)Overloaded. Adds a new NumericUpDown control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddNumericUpDown(Double, Double, Double, Double, String)Overloaded. Adds a new NumericUpDown control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddPictureBox(Range, String)Overloaded. Adds a new PictureBox control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddPictureBox(Double, Double, Double, Double, String)Overloaded. Adds a new PictureBox control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddProgressBar(Range, String)Overloaded. Adds a new ProgressBar control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddProgressBar(Double, Double, Double, Double, String)Overloaded. Adds a new ProgressBar control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddPropertyGrid(Range, String)Overloaded. Adds a new PropertyGrid control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddPropertyGrid(Double, Double, Double, Double, String)Overloaded. Adds a new PropertyGrid control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddRadioButton(Range, String)Overloaded. Adds a new RadioButton control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddRadioButton(Double, Double, Double, Double, String)Overloaded. Adds a new RadioButton control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddRichTextBox(Range, String)Overloaded. Adds a new RichTextBox control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddRichTextBox(Double, Double, Double, Double, String)Overloaded. Adds a new RichTextBox control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddTextBox(Range, String)Overloaded. Adds a new TextBox control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddTextBox(Double, Double, Double, Double, String)Overloaded. Adds a new TextBox control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddTrackBar(Range, String)Overloaded. Adds a new TrackBar control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddTrackBar(Double, Double, Double, Double, String)Overloaded. Adds a new TrackBar control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddTreeView(Range, String)Overloaded. Adds a new TreeView control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddTreeView(Double, Double, Double, Double, String)Overloaded. Adds a new TreeView control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddVScrollBar(Range, String)Overloaded. Adds a new VScrollBar control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddVScrollBar(Double, Double, Double, Double, String)Overloaded. Adds a new VScrollBar control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Public Extension MethodAddWebBrowser(Range, String)Overloaded. Adds a new WebBrowser control to the worksheet at the range specified. (Defined by ControlExtensions.)
Public Extension MethodAddWebBrowser(Double, Double, Double, Double, String)Overloaded. Adds a new WebBrowser control to the worksheet in the specified size and location. (Defined by ControlExtensions.)
Top

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 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 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.

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.

Usage

This documentation describes the version of this type that is used in Office projects that target the .NET Framework 4 and the .NET Framework 4.5. 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.

Show:
© 2014 Microsoft