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)

Syntax

'Declaration
<GuidAttribute("E1180F09-B903-4D03-8D30-2845219AEE2C")> _
Public Interface ControlCollection _
    Inherits IEnumerable
[GuidAttribute("E1180F09-B903-4D03-8D30-2845219AEE2C")]
public interface ControlCollection : IEnumerable

The ControlCollection type exposes the following members.

Properties

  Name Description
Public property Capacity Gets or sets the number of controls that the ControlCollection can contain.
Public property Count Gets the number of controls in the ControlCollection.
Public property Item[Int32] Gets the control at the specified index.
Public property Item[Object] Gets the specified control.
Public property Item[String] Gets the control with the specified name.

Top

Methods

  Name Description
Public method _VtblGap1_29 Infrastructure.
Public method AddBookmark(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 method AddBookmark(Range, String) Adds a new Bookmark control to the document at the specified range.
Public method AddBuildingBlockGalleryContentControl(String) Adds a new BuildingBlockGalleryContentControl at the current selection in the document.
Public method AddBuildingBlockGalleryContentControl(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 method AddBuildingBlockGalleryContentControl(Range, String) Adds a new BuildingBlockGalleryContentControl at the specified range in the document.
Public method AddComboBoxContentControl(String) Adds a new ComboBoxContentControl at the current selection in the document.
Public method AddComboBoxContentControl(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 method AddComboBoxContentControl(Range, String) Adds a new ComboBoxContentControl at the specified range in the document.
Public method AddContentControl(ContentControl, String) Adds a new ContentControl that is based on a native content control in the document.
Public method AddContentControl(String, WdContentControlType) Adds a new ContentControl of the specified type at the current selection in the document.
Public method AddContentControl(Range, String, WdContentControlType) Adds a new ContentControl of the specified type at the specified range in the document.
Public method AddControl(Control, Range, Single, Single, String) Adds the specified control to the ControlCollection at the specified range, with the specified size.
Public method AddControl(Control, Single, Single, Single, Single, String) Adds the specified control to the ControlCollection at the specified location, with the specified size.
Public method AddDatePickerContentControl(String) Adds a new DatePickerContentControl at the current selection in the document.
Public method AddDatePickerContentControl(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 method AddDatePickerContentControl(Range, String) Adds a new DatePickerContentControl at the specified range in the document.
Public method AddDropDownListContentControl(String) Adds a new DropDownListContentControl at the current selection in the document.
Public method AddDropDownListContentControl(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 method AddDropDownListContentControl(Range, String) Adds a new DropDownListContentControl at the specified range in the document.
Public method AddGroupContentControl(String) Adds a new GroupContentControl at the current selection in the document.
Public method AddGroupContentControl(ContentControl, String) Adds a new GroupContentControl that is based on a native content control in the document.
Public method AddGroupContentControl(Range, String) Adds a new GroupContentControl at the specified range in the document.
Public method AddPictureContentControl(String) Adds a new PictureContentControl at the current selection in the document.
Public method AddPictureContentControl(ContentControl, String) Adds a new PictureContentControl that is based on a native content control in the document.
Public method AddPictureContentControl(Range, String) Adds a new PictureContentControl at the specified range in the document.
Public method AddPlainTextContentControl(String) Adds a new PlainTextContentControl at the current selection in the document.
Public method AddPlainTextContentControl(ContentControl, String) Adds a new PlainTextContentControl that is based on a native content control in the document.
Public method AddPlainTextContentControl(Range, String) Adds a new PlainTextContentControl at the specified range in the document.
Public method AddRichTextContentControl(String) Adds a new RichTextContentControl at the current selection in the document.
Public method AddRichTextContentControl(ContentControl, String) Adds a new RichTextContentControl that is based on a native content control in the document.
Public method AddRichTextContentControl(Range, String) Adds a new RichTextContentControl at the specified range in the document.
Public method Contains(Object) Determines whether the specified control is a member of the ControlCollection instance.
Public method Contains(String) Determines whether a control with the specified name is a member of the ControlCollection instance.
Public method GetEnumerator Returns an enumerator that iterates through a collection. (Inherited from IEnumerable.)
Public method GetInlineShapeForControl Gets the underlying InlineShape for the specified control.
Public method GetShapeForControl Gets the underlying Shape for the specified control.
Public method IndexOf(Object) Searches for the specified control and returns the zero-based index of the first occurrence in the ControlCollection instance.
Public method IndexOf(String) Searches for the first occurrence of a control with the specified name in the ControlCollection instance.
Public method Remove(Object) Removes the specified control from the ControlCollection instance.
Public method Remove(String) Removes the specified control from the ControlCollection instance.
Public method RemoveAt Removes the control at the specified index in the ControlCollection instance.

Top

Extension Methods

  Name Description
Public Extension Method AddButton(Range, Single, Single, String) Overloaded. Adds a new Button control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddButton(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 Method AddCheckBox(Range, Single, Single, String) Overloaded. Adds a new CheckBox control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddCheckBox(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 Method AddCheckedListBox(Range, Single, Single, String) Overloaded. Adds a new CheckedListBox control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddCheckedListBox(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 Method AddComboBox(Range, Single, Single, String) Overloaded. Adds a new ComboBox control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddComboBox(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 Method AddDataGridView(Range, Single, Single, String) Overloaded. Adds a new DataGridView control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddDataGridView(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 Method AddDateTimePicker(Range, Single, Single, String) Overloaded. Adds a new DateTimePicker control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddDateTimePicker(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 Method AddDomainUpDown(Range, Single, Single, String) Overloaded. Adds a new DomainUpDown control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddDomainUpDown(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 Method AddHScrollBar(Range, Single, Single, String) Overloaded. Adds a new HScrollBar control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddHScrollBar(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 Method AddLabel(Range, Single, Single, String) Overloaded. Adds a new Label control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddLabel(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 Method AddLinkLabel(Range, Single, Single, String) Overloaded. Adds a new LinkLabel control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddLinkLabel(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 Method AddListBox(Range, Single, Single, String) Overloaded. Adds a new ListBox control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddListBox(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 Method AddListView(Range, Single, Single, String) Overloaded. Adds a new ListView control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddListView(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 Method AddMaskedTextBox(Range, Single, Single, String) Overloaded. Adds a new MaskedTextBox control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddMaskedTextBox(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 Method AddMonthCalendar(Range, Single, Single, String) Overloaded. Adds a new MonthCalendar control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddMonthCalendar(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 Method AddNumericUpDown(Range, Single, Single, String) Overloaded. Adds a new NumericUpDown control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddNumericUpDown(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 Method AddPictureBox(Range, Single, Single, String) Overloaded. Adds a new PictureBox control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddPictureBox(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 Method AddProgressBar(Range, Single, Single, String) Overloaded. Adds a new ProgressBar control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddProgressBar(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 Method AddPropertyGrid(Range, Single, Single, String) Overloaded. Adds a new PropertyGrid control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddPropertyGrid(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 Method AddRadioButton(Range, Single, Single, String) Overloaded. Adds a new RadioButton control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddRadioButton(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 Method AddRichTextBox(Range, Single, Single, String) Overloaded. Adds a new RichTextBox control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddRichTextBox(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 Method AddTextBox(Range, Single, Single, String) Overloaded. Adds a new TextBox control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddTextBox(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 Method AddTrackBar(Range, Single, Single, String) Overloaded. Adds a new TrackBar control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddTrackBar(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 Method AddTreeView(Range, Single, Single, String) Overloaded. Adds a new TreeView control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddTreeView(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 Method AddVScrollBar(Range, Single, Single, String) Overloaded. Adds a new VScrollBar control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddVScrollBar(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 Method AddWebBrowser(Range, Single, Single, String) Overloaded. Adds a new WebBrowser control to the document in the specified size and location. (Defined by ControlExtensions.)
Public Extension Method AddWebBrowser(Single, Single, Single, Single, String) Overloaded. Adds a new WebBrowser control to the document in the specified size and location. (Defined by ControlExtensions.)

Top

Remarks

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.

Note

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: https://go.microsoft.com/fwlink/?LinkId=160658.

See Also

Reference

Microsoft.Office.Tools.Word Namespace

Other Resources

Adding Controls to Office Documents at Run Time