Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ControlCollection Interface
Collapse the table of content
Expand the table of content

ControlCollection Interface

Represents a collection of managed controls on a Word document that has been customized by using the Office development tools in Visual Studio.

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

[GuidAttribute("E1180F09-B903-4D03-8D30-2845219AEE2C")]
public interface ControlCollection : IEnumerable

The ControlCollection type exposes the following members.

  NameDescription
Public propertyCapacityGets or sets the number of controls that the ControlCollection can contain.
Public propertyCountGets the number of controls in the ControlCollection.
Public propertyItem[Int32]Gets the control at the specified index.
Public propertyItem[Object]Gets the specified control.
Public propertyItem[String]Gets the control with the specified name.
Top

  NameDescription
Public method_VtblGap1_29Infrastructure.
Public methodAddBookmark(Bookmark, String)Adds a new Microsoft.Office.Tools.Word.Bookmark control to the document at the location of the existing Microsoft.Office.Interop.Word.Bookmark specified.
Public methodAddBookmark(Range, String)Adds a new Bookmark control to the document at the specified range.
Public methodAddBuildingBlockGalleryContentControl(String)Adds a new BuildingBlockGalleryContentControl at the current selection in the document.
Public methodAddBuildingBlockGalleryContentControl(ContentControl, String)Adds a new BuildingBlockGalleryContentControl to the collection. The new control is based on a native content control that is already in the document.
Public methodAddBuildingBlockGalleryContentControl(Range, String)Adds a new BuildingBlockGalleryContentControl at the specified range in the document.
Public methodAddComboBoxContentControl(String)Adds a new ComboBoxContentControl at the current selection in the document.
Public methodAddComboBoxContentControl(ContentControl, String)Adds a new ComboBoxContentControl to the collection. The new control is based on a native content control that is already in the document.
Public methodAddComboBoxContentControl(Range, String)Adds a new ComboBoxContentControl at the specified range in the document.
Public methodAddContentControl(ContentControl, String)Adds a new ContentControl that is based on a native content control in the document.
Public methodAddContentControl(String, WdContentControlType)Adds a new ContentControl of the specified type at the current selection in the document.
Public methodAddContentControl(Range, String, WdContentControlType)Adds a new ContentControl of the specified type at the specified range in the document.
Public methodAddControl(Control, Range, Single, Single, String)Adds the specified control to the ControlCollection at the specified range, with the specified size.
Public methodAddControl(Control, Single, Single, Single, Single, String)Adds the specified control to the ControlCollection at the specified location, with the specified size.
Public methodAddDatePickerContentControl(String)Adds a new DatePickerContentControl at the current selection in the document.
Public methodAddDatePickerContentControl(ContentControl, String)Adds a new DatePickerContentControl to the collection. The new control is based on a native content control that is already in the document.
Public methodAddDatePickerContentControl(Range, String)Adds a new DatePickerContentControl at the specified range in the document.
Public methodAddDropDownListContentControl(String)Adds a new DropDownListContentControl at the current selection in the document.
Public methodAddDropDownListContentControl(ContentControl, String)Adds a new DropDownListContentControl to the collection. The new control is based on a native content control that is already in the document.
Public methodAddDropDownListContentControl(Range, String)Adds a new DropDownListContentControl at the specified range in the document.
Public methodAddGroupContentControl(String)Adds a new GroupContentControl at the current selection in the document.
Public methodAddGroupContentControl(ContentControl, String)Adds a new GroupContentControl that is based on a native content control in the document.
Public methodAddGroupContentControl(Range, String)Adds a new GroupContentControl at the specified range in the document.
Public methodAddPictureContentControl(String)Adds a new PictureContentControl at the current selection in the document.
Public methodAddPictureContentControl(ContentControl, String)Adds a new PictureContentControl that is based on a native content control in the document.
Public methodAddPictureContentControl(Range, String)Adds a new PictureContentControl at the specified range in the document.
Public methodAddPlainTextContentControl(String)Adds a new PlainTextContentControl at the current selection in the document.
Public methodAddPlainTextContentControl(ContentControl, String)Adds a new PlainTextContentControl that is based on a native content control in the document.
Public methodAddPlainTextContentControl(Range, String)Adds a new PlainTextContentControl at the specified range in the document.
Public methodAddRichTextContentControl(String)Adds a new RichTextContentControl at the current selection in the document.
Public methodAddRichTextContentControl(ContentControl, String)Adds a new RichTextContentControl that is based on a native content control in the document.
Public methodAddRichTextContentControl(Range, String)Adds a new RichTextContentControl at the specified range in the document.
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 methodGetInlineShapeForControlGets the underlying InlineShape for the specified control.
Public methodGetShapeForControlGets the underlying Shape for the specified control.
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 specified control from the ControlCollection instance.
Public methodRemoveAtRemoves the control at the specified index in the ControlCollection instance.
Top

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

Use the ControlCollection methods and properties to manage controls on a Word document. For more information, see Adding Controls to Office Documents at Run Time.

To get an ControlCollection object in a document-level project, use the Controls property of the ThisDocument class in your project. To get an ControlCollection object in an application-level project, use the Controls property of a Document 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 document.

Use one of the AddControlName methods. For example, to add a content control, use the AddContentControl method.

Remove a control from the document.

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:
© 2015 Microsoft