ContentControl 類別 (2007 系統)

更新:2007 年 11 月

表示文件中的內容控制項。

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

語法

<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public NotInheritable Class ContentControl _
    Inherits ContentControlBase _
    Implements ISupportInitializeControl, ISupportInitialize

Dim instance As ContentControl
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public sealed class ContentControl : ContentControlBase, 
    ISupportInitializeControl, ISupportInitialize

備註

ContentControl 物件是可變動的控制項,代表可在 Microsoft Office Word 中使用的八種內容控制項中的任何一種。例如,如果您建立一個 ContentControl,其起始功能為純文字控制項,您可以在執行階段將它變更,使其行為像下拉式方塊。Visual Studio Tools for Office 中的其他內容控制項類別就不能這麼使用。例如,RichTextContentControl 物件只能代表 Rich Text 控制項。如需內容控制項的詳細資訊,請參閱內容控制項.

若要建立 ContentControl,請使用其中一種 AddContentControl 方法。您不能在設計階段將 ContentControl 加入至文件。

建立 ContentControl 時,必須指定您要建立之內容控制項的型別,或者可以使用現有的內容控制項做為新控制項的基礎。建立了 ContentControl 後,可以使用 Type 屬性,變更它所代表的內容控制項型別。

當控制項設定成不是用來使用成員的控制項型別時,如果您使用 ContentControl 成員,其中有些成員會擲回例外狀況。例如,如果您嘗試在不是代表日期選擇器的 ContentControl 上使用 DateCalendarType 屬性,則該屬性會擲回例外狀況。

繼承階層架構

System.Object
  Microsoft.VisualStudio.Tools.Office.RemoteComponent
    Microsoft.VisualStudio.Tools.Office.RemoteBindableComponent
      Microsoft.Office.Tools.Word.ContentControlBase
        Microsoft.Office.Tools.Word.ContentControl

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。

請參閱

參考

ContentControl 成員

Microsoft.Office.Tools.Word 命名空間

其他資源

內容控制項

HOW TO:將內容控制項加入至 Word 文件

HOW TO:使用內容控制項保護文件的部分