ControlCollection 介面

表示使用 Visual Studio 的 Office 開發工具所自訂之 Word 文件上的 Managed 控制項集合。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

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

ControlCollection 型別會公開下列成員。

屬性

  名稱 說明
公用屬性 Capacity 取得或設定 ControlCollection 可以包含的控制項數目。
公用屬性 Count 取得 ControlCollection 中的控制項數目。
公用屬性 Item[Int32] 取得指定索引上的控制項。
公用屬性 Item[Object] 取得指定的控制項。
公用屬性 Item[String] 取得具有指定名稱的控制項。

回頁首

方法

  名稱 說明
公用方法 AddBookmark(Bookmark, String) 將新的 Microsoft.Office.Tools.Word.Bookmark 控制項加入至指定之現有 Microsoft.Office.Interop.Word.Bookmark 位置的文件中。
公用方法 AddBookmark(Range, String) 將新的 Bookmark 控制項加入至文件中指定的範圍內。
公用方法 AddBuildingBlockGalleryContentControl(String) 在文件中目前的選取位置加入新的 BuildingBlockGalleryContentControl
公用方法 AddBuildingBlockGalleryContentControl(ContentControl, String) 將新的 BuildingBlockGalleryContentControl 加入集合中。新的控制項是以文件中已有的原生內容控制項為基礎。
公用方法 AddBuildingBlockGalleryContentControl(Range, String) 將新的 BuildingBlockGalleryContentControl 加入至文件中指定的範圍內。
公用方法 AddComboBoxContentControl(String) 在文件中目前的選取位置加入新的 ComboBoxContentControl
公用方法 AddComboBoxContentControl(ContentControl, String) 將新的 ComboBoxContentControl 加入集合中。新的控制項是以文件中已有的原生內容控制項為基礎。
公用方法 AddComboBoxContentControl(Range, String) 將新的 ComboBoxContentControl 加入至文件中指定的範圍內。
公用方法 AddContentControl(ContentControl, String) 加入新的 ContentControl,此控制項是以文件中的原生內容控制項為基礎。
公用方法 AddContentControl(String, WdContentControlType) 在文件中目前的選取位置上,加入指定型別之新的 ContentControl
公用方法 AddContentControl(Range, String, WdContentControlType) 在文件中指定的範圍,加入指定型別之新的 ContentControl
公用方法 AddControl(Control, Range, Single, Single, String) 將具有指定大小的指定控制項加入至指定範圍內的 ControlCollection。
公用方法 AddControl(Control, Single, Single, Single, Single, String) 將具有指定大小的指定控制項加入至指定位置的 ControlCollection。
公用方法 AddDatePickerContentControl(String) 在文件中目前的選取位置加入新的 DatePickerContentControl
公用方法 AddDatePickerContentControl(ContentControl, String) 將新的 DatePickerContentControl 加入集合中。新的控制項是以文件中已有的原生內容控制項為基礎。
公用方法 AddDatePickerContentControl(Range, String) 將新的 DatePickerContentControl 加入至文件中指定的範圍內。
公用方法 AddDropDownListContentControl(String) 在文件中目前的選取位置加入新的 DropDownListContentControl
公用方法 AddDropDownListContentControl(ContentControl, String) 將新的 DropDownListContentControl 加入集合中。新的控制項是以文件中已有的原生內容控制項為基礎。
公用方法 AddDropDownListContentControl(Range, String) 將新的 DropDownListContentControl 加入至文件中指定的範圍內。
公用方法 AddGroupContentControl(String) 在文件中目前的選取位置加入新的 GroupContentControl
公用方法 AddGroupContentControl(ContentControl, String) 加入新的 GroupContentControl,此控制項是以文件中的原生內容控制項為基礎。
公用方法 AddGroupContentControl(Range, String) 將新的 GroupContentControl 加入至文件中指定的範圍內。
公用方法 AddPictureContentControl(String) 在文件中目前的選取位置加入新的 PictureContentControl
公用方法 AddPictureContentControl(ContentControl, String) 加入新的 PictureContentControl,此控制項是以文件中的原生內容控制項為基礎。
公用方法 AddPictureContentControl(Range, String) 將新的 PictureContentControl 加入至文件中指定的範圍內。
公用方法 AddPlainTextContentControl(String) 在文件中目前的選取位置加入新的 PlainTextContentControl
公用方法 AddPlainTextContentControl(ContentControl, String) 加入新的 PlainTextContentControl,此控制項是以文件中的原生內容控制項為基礎。
公用方法 AddPlainTextContentControl(Range, String) 將新的 PlainTextContentControl 加入至文件中指定的範圍內。
公用方法 AddRichTextContentControl(String) 在文件中目前的選取位置加入新的 RichTextContentControl
公用方法 AddRichTextContentControl(ContentControl, String) 加入新的 RichTextContentControl,此控制項是以文件中的原生內容控制項為基礎。
公用方法 AddRichTextContentControl(Range, String) 將新的 RichTextContentControl 加入至文件中指定的範圍內。
公用方法 Contains(Object) 判斷指定的控制項是否為 ControlCollection 執行個體的成員。
公用方法 Contains(String) 判斷具有指定名稱的控制項是否為 ControlCollection 執行個體的成員。
公用方法 GetEnumerator 傳回會逐一查看集合的列舉程式。 (繼承自 IEnumerable)。
公用方法 GetInlineShapeForControl 取得指定之控制項的基礎 InlineShape
公用方法 GetShapeForControl 取得指定之控制項的基礎 Shape
公用方法 IndexOf(Object) 在 ControlCollection 執行個體中搜尋指定的控制項,並傳回第一次出現的位置索引 (以零起始)。
公用方法 IndexOf(String) 搜尋在 ControlCollection 執行個體中具有指定名稱的控制項的第一個項目。
公用方法 Remove(Object) 從 ControlCollection 執行個體中移除指定的控制項。
公用方法 Remove(String) 從 ControlCollection 執行個體中移除指定的控制項。
公用方法 RemoveAt 移除 ControlCollection 執行個體中指定索引的控制項。

回頁首

備註

使用 ControlCollection 方法和屬性管理 Word 文件上的控制項。 如需詳細資訊,請參閱在執行階段將控制項加入至 Office 文件

若要在文件層級專案中取得 ControlCollection 物件,請在專案中使用 ThisDocument 類別的 Controls 屬性。 若要在應用程式層級專案中取得 ControlCollection 物件,請使用在執行階段中以程式設計方式建立的 Document 主項目其 Controls 屬性。 如需詳細資訊,請參閱在應用程式層級增益集的執行階段中擴充 Word 文件和 Excel 活頁簿

下表顯示如何使用 ControlCollection 成員,執行一些與文件上之控制項相關的一般工作。

工作

動作

將控制項加入至文件。

使用其中一種 AddControlName 方法。 例如,若要加入內容控制項,請使用 AddContentControl 方法。

從文件移除控制項。

請使用 Remove 方法。

判斷控制項是否在集合中。

將控制項或其名稱傳送給 Contains 方法。

取得集合中控制項的索引。

將控制項或其名稱傳送給 IndexOf 方法。

從集合取得控制項。

將索引或控制項的名稱傳遞至 Item 屬性。

注意事項注意事項

此介面是由 Visual Studio Tools for Office Runtime 所實作, 並不能實作於您的程式碼中。 如需詳細資訊,請參閱 Visual Studio Tools for Office Runtime 概觀

使用方式

本文件說明此型別用於以 .NET Framework 4 為目標之 Office 專案的版本。在以 .NET Framework 3.5 為目標的專案中,此型別可能會有不同的成員,而為此型別提供的程式碼範例可能無法運作。 如需此型別在以 .NET Framework 3.5 為目標之專案中的相關文件,請參閱下列 Visual Studio 2008 文件中的參考章節:https://go.microsoft.com/fwlink/?LinkId=160658 (英文)。

請參閱

參考

Microsoft.Office.Tools.Word 命名空間

其他資源

在執行階段將控制項加入至 Office 文件

主控制項的 Helper 方法