跳到主要内容

ReplaceByElement

用新元素替换当前内容控件。

语法

expression.ReplaceByElement(oElement);

expression - 表示 ApiBlockLvlSdt 类的变量。

参数

名称必需/可选数据类型默认值描述
oElement必需DocumentElement用于替换当前内容控件的元素。

返回值

boolean

示例

此示例用段落替换内容控件。

// How to replace the block content control with another document element (paragraph, table, or block content control).

// Creates the ApiBlockLvlSdt object and replaces it with the ApiParagraph object.

// Replaces the block level content control with a text.

let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
doc.AddElement(0, blockLvlSdt);
blockLvlSdt.SetPlaceholderText("Name");
let paragraph = Api.CreateParagraph();
paragraph.AddText("The content control was replaced with the current paragraph.");
blockLvlSdt.ReplaceByElement(paragraph);