跳到主要内容

GetValue

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

语法

expression.GetValue();

expression - 表示 ApiContentControlListEntry 类的变量。

参数

此方法没有任何参数。

返回值

string

示例

读取文档中为下拉列表或组合框列表条目存储的底层值。

// How do I get the value assigned to a list item in a document?

// Extract the programmatic value of an entry when the display label alone is not enough in a document.

let doc = Api.GetDocument();
let cc = Api.CreateComboBoxContentControl([{display: "Mercury", value: "planet1"}, {display: "Venus", value: "planet2"}, {display: "Earth", value: "planet3"}, {display: "Mars", value: "planet4"}], 2);
let contentControlList = cc.GetDropdownList();
let listItem = contentControlList.GetItem(1);
let paragraph = Api.CreateParagraph();
let value = listItem.GetValue();
paragraph.AddText("Value of the content control list entry: " + value);
doc.AddElement(0, paragraph);