ContentControl 接口

定义

单个内容控件。An individual content control. 内容控件是文档中绑定的、有可能添加标签的区域,它们充当特定类型的内容的容器。Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. 单个内容控件可能包含诸如日期、列表或格式化文本段落等内容。Individual content controls may contain contents such as dates, lists, or paragraphs of formatted text. ContentControl对象是集合的一个成员 ContentControlsThe ContentControl object is a member of the ContentControls collection.

public interface class ContentControl
[System.Runtime.InteropServices.Guid("EE95AFE3-3026-4172-B078-0E79DAB5CC3D")]
public interface ContentControl
type ContentControl = interface
Public Interface ContentControl
属性

注解

使用 Add(WdContentControlType, Object) 集合的方法 ContentControls 创建内容控件。Use the Add(WdContentControlType, Object) method of the ContentControls collection to create a content control. 使用 Type Add方法的参数指定要创建的内容控件的类型。Use the Type parameter of the Add method to specify the type of content control to create.

使用 Type 属性将内容控件更改为其他类型的内容控件。Use the Type property to change the content control to a different type of content control. 例如,你也许要从日期控件更改为文本控件。For example, perhaps you want to change from a date control to a text control. 但是,你可能无法将所有内容控件更改为其他类型;某些控件可能不允许更改其类型。However, you may not be able to change all content controls to another type; some may not allow changing their type. 此外,根据内容控件的内容,可能无法更改类型。In addition, depending on the contents of a content control, you may not be able to change the type. 例如,想要更改的内容控件不允许使用现有内容控件中的内容类型,如果尝试更改类型是不允许的,并且将产生运行时错误。For example, if the content control that you want to change to does not allow the type of content that is in the existing content control, attempting to change the type is not allowed and generates a run-time error.

使用 SetPlaceholderText(BuildingBlock, Range, String) 方法可将默认字符串中的占位符文本更改为更适合控件的文本。Use the SetPlaceholderText(BuildingBlock, Range, String) method to change the placeholder text from the default string to something more appropriate for the control. 使用 Title 属性指定控件的标题文本。Use the Title property to specify the title text for the control. 当光标定位在控件内部或鼠标指针置于控件上时,这些内容将显示在控件上。This displays above the control when the cursor is positioned inside the control or the mouse pointer is positioned over the control.

根据所拥有的内容控件的类型,你可能无法使用 ContentControl 对象的所有属性和方法。Depending on the type of content control that you have, you may not be able to use all the properties and methods of the ContentControl object.

Not all content control properties apply to all the different types of content controls. The following table lists which properties apply to which types of content controls.

BuildingBlockCategory propertyBuildingBlock Gallery content controls (wdContentControlBuildingBlockGallery)
BuildingBlockType propertyBuildingBlock Gallery content controls (wdContentControlBuildingBlockGallery)
DateDisplayFormat propertyDate content controls (wdContentControlDate)
DateDisplayLocale propertyDate content controls (wdContentControlDate)
DateStorageFormat propertyDate content controls (wdContentControlDate)
DropdownListEntries propertyCombo box and drop-down list content controls (wdContentControlComboBox and wdContentControlDropdownList)
MultiLine propertyPlain text content controls (wdContentControlText)
Ungroup() methodGroup content controls (wdContentControlGroup)

属性

AllowInsertDeleteSection

获取或设置用户是否可以使用用户界面在指定的重复节内容控件中添加或删除节。Gets or sets whether users can add or remove sections from the specified repeating section content control by using the user interface.

Appearance

返回或设置内容控件的外观。Returns or sets the appearance of the content control. 读/写WdContentControlAppearanceRead/write WdContentControlAppearance

Application

返回一个 _Application 对象,表示 Microsoft Word 应用程序。Returns an _Application object that represents the Microsoft Word application.

BuildingBlockCategory

返回或设置构建基块内容控件的类别。Returns or sets the category for a building block content control. 读/写。Read/write.

BuildingBlockType

返回或设置构建基块内容控件的构建基块的类型。Returns or sets the type of building block for a building block content control. 读/写。Read/write.

Checked

获取或设置复选框的当前状态(选中/未选中)。Gets or sets the current state (checked/unchecked) for a check box.

Color

返回或设置内容控件的颜色。Returns or sets the color of the content control. 读/写 WdColorRead/write WdColor.

Creator

返回一个 32 位整数,它指示在其中创建外接程序的应用程序。Returns a 32-bit integer that indicates the application in which the add-in was created. 只读。Read-only.

DateCalendarType

返回或设置日历内容控件的日历类型。Returns or sets the calendar type for a calendar content control. 读/写。Read/write.

DateDisplayFormat

返回或设置日期的显示格式。Returns or sets the format in which dates are displayed. 读/写。Read/write.

DateDisplayLocale

返回日期内容控件中显示的日期的语言格式。Returns a the language format for the date displayed in a date content control. 读/写。Read/write.

DateStorageFormat

返回或设置日期内容控件绑定到活动文档的 XML 数据存储区时存储和检索日期的格式。Returns or sets the format for storage and retrieval of dates when a date content control is bound to the XML data store of the active document. 读/写。Read/write.

DefaultTextStyle

返回或设置用于设置文本内容控件中文本的格式的字符样式的名称。Returns or sets the name of the character style to use to format text in a text content control. 读/写。Read/write.

DropdownListEntries

返回下拉列表内容控件或组合框内容控件中的项。Returns the items in a drop-down list content control or in a combo box content control. 只读。Read-only.

ID

返回内容控件的标识。Returns the identification for a content control. 只读。Read-only.

Level

返回内容控件的级别—内容控件是围绕文本、段落、表格单元格还是表格行。或者如果是内联的。Returns the level of the content control—whether the content control surrounds text, paragraphs, table cells, or table rows; or if it is inline. 只读 WdContentControlLevelRead-only WdContentControlLevel.

LockContentControl

返回或设置一个 boolean 类型的值 ,该值表示用户能否从活动文档中删除内容控件。Returns or sets a Boolean that represents whether the user can delete a content control from the active document. 读/写。Read/write.

LockContents

返回或设置一个 boolean 类型的值 ,该值表示用户能否编辑内容控件的内容。Returns or sets a Boolean that represents whether the user can edit the contents of a content control. 读/写。Read/write.

MultiLine

返回一个 boolean 类型的值 ,该值表示一个文本内容控件是否允许多行文本。Returns a Boolean that represents whether a text content control allows multiple lines of text. 读/写。Read/write.

Parent

返回一个代表指定对象的父对象的 ContentControlReturns an that represents the parent object of the specified ContentControl object.

ParentContentControl

返回嵌套在丰富文本控件或组控件中的内容控件的父内容控件。Returns the parent content control for a content control that is nested inside a rich-text control or group control. 只读。Read-only.

PlaceholderText

返回一个 BuildingBlock 对象,表示内容控件的占位符文本。Returns a BuildingBlock object that represents the placeholder text for a content control. 只读。Read-only.

Range

返回一个 Range 表示活动文档中内容控件的内容的。Returns a Range that represents the contents of the content control in the active document. 只读。Read-only.

RepeatingSectionItems

返回指定的重复节内容控件中的重复节项的集合。Returns the collection of repeating section items in the specified repeating section content control. 只读。Read-only.

RepeatingSectionItemTitle

返回或设置与指定的重复节内容控件相关联的上下文菜单中使用的重复节项的名称。Returns or sets the name of the repeating section items used in the context menu associated with the specified repeating section content control. 读/写。Read/write.

ShowingPlaceholderText

返回一个 boolean 类型的值 ,该值指示是否显示占位符文本的内容控件。Returns a Boolean that indicates whether the placeholder text for the content control is displayed. 只读的。Read-only.

Tag

返回或设置一个值,用于标识内容控件。Returns or sets a value to identify a content control. 读/写。Read/write.

Temporary

返回或设置一个 boolean 类型的值 ,该值代表是否从活动文档中删除内容控件,当用户编辑控件的内容。读/写。Returns or sets a Boolean that represents whether to remove a content control from the active document when the user edits the contents of the control. Read/write.

Title

返回或设置内容控件的标题。Returns or sets the title for a content control. 读/写。Read/write.

Type

返回或设置内容控件的类型。Returns or sets the type for a content control. 读/写。Read/write.

XMLMapping

返回一个内容控件到文档数据存储区中的 XML 数据的映射。Returns the mapping of a content control to XML data in the data store of a document. 只读。Read-only.

方法

Copy()

将活动文档中的内容控件复制到剪贴板。Copies the content control from the active document to the Clipboard.

Cut()

从活动文档中删除内容控件并将该内容控件移动到剪贴板中。Removes the content control from the active document and moves the content control to the Clipboard.

Delete(Boolean)

删除指定的内容控件以及内容控件中的内容。Deletes the specified content control and the contents of the content control.

SetCheckedSymbol(Int32, String)

设置用于代表复选框内容控件的选中状态的符号。Sets the symbol used to represent the checked state of a check box content control.

SetPlaceholderText(BuildingBlock, Range, String)

设置在用户输入自己的文本之前显示在内容控件中的占位符文本。Sets the placeholder text that displays in the content control until a user enters their own text.

SetUncheckedSymbol(Int32, String)

设置用于代表复选框内容控件的未选中状态的符号。Sets the symbol used to represent the unchecked state of a check box content control.

Ungroup()

从文档中删除一个组内容控件,以便它的子内容控件不再嵌套,并且可以自由地进行编辑。Removes a group content control from a document so that its child content controls are no longer nested and can be freely edited.

适用于