Compartilhar via


ControlCollection Interface

Definition

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

public interface class ControlCollection : System::Collections::IEnumerable
[System.Runtime.InteropServices.Guid("E1180F09-B903-4D03-8D30-2845219AEE2C")]
public interface ControlCollection : System.Collections.IEnumerable
[<System.Runtime.InteropServices.Guid("E1180F09-B903-4D03-8D30-2845219AEE2C")>]
type ControlCollection = interface
    interface IEnumerable
Public Interface ControlCollection
Implements IEnumerable
Attributes
Implements

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

Properties

Capacity

Gets or sets the number of controls that the ControlCollection can contain.

Count

Gets the number of controls in the ControlCollection.

Item[Int32]

Gets the control at the specified index.

Item[Object]

Gets the specified control.

Item[String]

Gets the control with the specified name.

Methods

AddBookmark(Bookmark, String)

Adds a new Bookmark control to the document at the location of the existing Bookmark specified.

AddBookmark(Range, String)

Adds a new Bookmark control to the document at the specified range.

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.

AddBuildingBlockGalleryContentControl(Range, String)

Adds a new BuildingBlockGalleryContentControl at the specified range in the document.

AddBuildingBlockGalleryContentControl(String)

Adds a new BuildingBlockGalleryContentControl at the current selection in the document.

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.

AddComboBoxContentControl(Range, String)

Adds a new ComboBoxContentControl at the specified range in the document.

AddComboBoxContentControl(String)

Adds a new ComboBoxContentControl at the current selection in the document.

AddContentControl(ContentControl, String)

Adds a new ContentControl that is based on a native content control in the document.

AddContentControl(Range, String, WdContentControlType)

Adds a new ContentControl of the specified type at the specified range in the document.

AddContentControl(String, WdContentControlType)

Adds a new ContentControl of the specified type at the current selection in the document.

AddControl(Control, Range, Single, Single, String)

Adds the specified control to the ControlCollection at the specified range, with the specified size.

AddControl(Control, Single, Single, Single, Single, String)

Adds the specified control to the ControlCollection at the specified location, with the specified size.

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.

AddDatePickerContentControl(Range, String)

Adds a new DatePickerContentControl at the specified range in the document.

AddDatePickerContentControl(String)

Adds a new DatePickerContentControl at the current selection in the document.

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.

AddDropDownListContentControl(Range, String)

Adds a new DropDownListContentControl at the specified range in the document.

AddDropDownListContentControl(String)

Adds a new DropDownListContentControl at the current selection in the document.

AddGroupContentControl(ContentControl, String)

Adds a new GroupContentControl that is based on a native content control in the document.

AddGroupContentControl(Range, String)

Adds a new GroupContentControl at the specified range in the document.

AddGroupContentControl(String)

Adds a new GroupContentControl at the current selection in the document.

AddPictureContentControl(ContentControl, String)

Adds a new PictureContentControl that is based on a native content control in the document.

AddPictureContentControl(Range, String)

Adds a new PictureContentControl at the specified range in the document.

AddPictureContentControl(String)

Adds a new PictureContentControl at the current selection in the document.

AddPlainTextContentControl(ContentControl, String)

Adds a new PlainTextContentControl that is based on a native content control in the document.

AddPlainTextContentControl(Range, String)

Adds a new PlainTextContentControl at the specified range in the document.

AddPlainTextContentControl(String)

Adds a new PlainTextContentControl at the current selection in the document.

AddRichTextContentControl(ContentControl, String)

Adds a new RichTextContentControl that is based on a native content control in the document.

AddRichTextContentControl(Range, String)

Adds a new RichTextContentControl at the specified range in the document.

AddRichTextContentControl(String)

Adds a new RichTextContentControl at the current selection in the document.

Contains(Object)

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

Contains(String)

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

GetInlineShapeForControl(Control)

Gets the underlying InlineShape for the specified control.

GetShapeForControl(Control)

Gets the underlying Shape for the specified control.

IndexOf(Object)

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

IndexOf(String)

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

Remove(Object)

Removes the specified control from the ControlCollection instance.

Remove(String)

Removes the specified control from the ControlCollection instance.

RemoveAt(Int32)

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

Extension Methods

AddButton(ControlCollection, Range, Single, Single, String)

Adds a new Button control to the document in the specified size and location.

AddButton(ControlCollection, Single, Single, Single, Single, String)

Adds a new Button control to the document in the specified size and location.

AddCheckBox(ControlCollection, Range, Single, Single, String)

Adds a new CheckBox control to the document in the specified size and location.

AddCheckBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new CheckBox control to the document in the specified size and location.

AddCheckedListBox(ControlCollection, Range, Single, Single, String)

Adds a new CheckedListBox control to the document in the specified size and location.

AddCheckedListBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new CheckedListBox control to the document in the specified size and location.

AddComboBox(ControlCollection, Range, Single, Single, String)

Adds a new ComboBox control to the document in the specified size and location.

AddComboBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new ComboBox control to the document in the specified size and location.

AddDataGridView(ControlCollection, Range, Single, Single, String)

Adds a new DataGridView control to the document in the specified size and location.

AddDataGridView(ControlCollection, Single, Single, Single, Single, String)

Adds a new DataGridView control to the document in the specified size and location.

AddDateTimePicker(ControlCollection, Range, Single, Single, String)

Adds a new DateTimePicker control to the document in the specified size and location.

AddDateTimePicker(ControlCollection, Single, Single, Single, Single, String)

Adds a new DateTimePicker control to the document in the specified size and location.

AddDomainUpDown(ControlCollection, Range, Single, Single, String)

Adds a new DomainUpDown control to the document in the specified size and location.

AddDomainUpDown(ControlCollection, Single, Single, Single, Single, String)

Adds a new DomainUpDown control to the document in the specified size and location.

AddHScrollBar(ControlCollection, Range, Single, Single, String)

Adds a new HScrollBar control to the document in the specified size and location.

AddHScrollBar(ControlCollection, Single, Single, Single, Single, String)

Adds a new HScrollBar control to the document in the specified size and location.

AddLabel(ControlCollection, Range, Single, Single, String)

Adds a new Label control to the document in the specified size and location.

AddLabel(ControlCollection, Single, Single, Single, Single, String)

Adds a new Label control to the document in the specified size and location.

AddLinkLabel(ControlCollection, Range, Single, Single, String)

Adds a new LinkLabel control to the document in the specified size and location.

AddLinkLabel(ControlCollection, Single, Single, Single, Single, String)

Adds a new LinkLabel control to the document in the specified size and location.

AddListBox(ControlCollection, Range, Single, Single, String)

Adds a new ListBox control to the document in the specified size and location.

AddListBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new ListBox control to the document in the specified size and location.

AddListView(ControlCollection, Range, Single, Single, String)

Adds a new ListView control to the document in the specified size and location.

AddListView(ControlCollection, Single, Single, Single, Single, String)

Adds a new ListView control to the document in the specified size and location.

AddMaskedTextBox(ControlCollection, Range, Single, Single, String)

Adds a new MaskedTextBox control to the document in the specified size and location.

AddMaskedTextBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new MaskedTextBox control to the document in the specified size and location.

AddMonthCalendar(ControlCollection, Range, Single, Single, String)

Adds a new MonthCalendar control to the document in the specified size and location.

AddMonthCalendar(ControlCollection, Single, Single, Single, Single, String)

Adds a new MonthCalendar control to the document in the specified size and location.

AddNumericUpDown(ControlCollection, Range, Single, Single, String)

Adds a new NumericUpDown control to the document in the specified size and location.

AddNumericUpDown(ControlCollection, Single, Single, Single, Single, String)

Adds a new NumericUpDown control to the document in the specified size and location.

AddPictureBox(ControlCollection, Range, Single, Single, String)

Adds a new PictureBox control to the document in the specified size and location.

AddPictureBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new PictureBox control to the document in the specified size and location.

AddProgressBar(ControlCollection, Range, Single, Single, String)

Adds a new ProgressBar control to the document in the specified size and location.

AddProgressBar(ControlCollection, Single, Single, Single, Single, String)

Adds a new ProgressBar control to the document in the specified size and location.

AddPropertyGrid(ControlCollection, Range, Single, Single, String)

Adds a new PropertyGrid control to the document in the specified size and location.

AddPropertyGrid(ControlCollection, Single, Single, Single, Single, String)

Adds a new PropertyGrid control to the document in the specified size and location.

AddRadioButton(ControlCollection, Range, Single, Single, String)

Adds a new RadioButton control to the document in the specified size and location.

AddRadioButton(ControlCollection, Single, Single, Single, Single, String)

Adds a new RadioButton control to the document in the specified size and location.

AddRichTextBox(ControlCollection, Range, Single, Single, String)

Adds a new RichTextBox control to the document in the specified size and location.

AddRichTextBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new RichTextBox control to the document in the specified size and location.

AddTextBox(ControlCollection, Range, Single, Single, String)

Adds a new TextBox control to the document in the specified size and location.

AddTextBox(ControlCollection, Single, Single, Single, Single, String)

Adds a new TextBox control to the document in the specified size and location.

AddTrackBar(ControlCollection, Range, Single, Single, String)

Adds a new TrackBar control to the document in the specified size and location.

AddTrackBar(ControlCollection, Single, Single, Single, Single, String)

Adds a new TrackBar control to the document in the specified size and location.

AddTreeView(ControlCollection, Range, Single, Single, String)

Adds a new TreeView control to the document in the specified size and location.

AddTreeView(ControlCollection, Single, Single, Single, Single, String)

Adds a new TreeView control to the document in the specified size and location.

AddVScrollBar(ControlCollection, Range, Single, Single, String)

Adds a new VScrollBar control to the document in the specified size and location.

AddVScrollBar(ControlCollection, Single, Single, Single, Single, String)

Adds a new VScrollBar control to the document in the specified size and location.

AddWebBrowser(ControlCollection, Range, Single, Single, String)

Adds a new WebBrowser control to the document in the specified size and location.

AddWebBrowser(ControlCollection, Single, Single, Single, Single, String)

Adds a new WebBrowser control to the document in the specified size and location.

Applies to