跳到主要内容

SetValue

设置表示组合框/下拉列表内容控件列表项值的字符串。

语法

expression.SetValue(sValue);

expression - 表示 ApiContentControlListEntry 类的变量。

参数

名称必需/可选数据类型默认值描述
sValue必需string列表项的值。

返回值

boolean

示例

此示例设置下拉列表或组合框内容控件中列表项的显示文本字符串。

let doc = Api.GetDocument();
let cc = Api.CreateComboBoxContentControl([{display: "Mercury", value: "planet1"}, {display: "Venus", value: "planet2"}, {display: "Earth", value: "planet3"}, {display: "Mars", value: "planet4"}]);
let paragraph = doc.GetElement(0);
let contentControlList = cc.GetDropdownList();
paragraph.Push(cc);
let listItem = contentControlList.GetItem(2);
listItem.SetValue("Home");
listItem.Select();
paragraph = Api.CreateParagraph();
paragraph.AddText("Value of third item in list: " + listItem.GetValue());
doc.AddElement(0, paragraph);