Skip to main content

AddListItem

Adds an item to a combo box list or drop-down list.

Syntax​

expression.AddListItem(name, value, pos);

expression - A variable that represents an ApiInlineLvlSdt class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
nameRequiredstringThe name of the item to add to the list.
valueRequiredstringThe value of the item to add to the list.
posOptionalnumberThe optional position at which to insert the new item in the list.

Returns​

boolean

Example​

Add items to a combobox content control and select one in a document.

// How do I populate a combobox content control with list items in a document?

// Build a dropdown list inside a content control and set its active value in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let contentControl = doc.AddComboBoxContentControl();
let paragraph1 = Api.CreateParagraph();
contentControl.AddListItem('one', '1');
contentControl.AddListItem('two', '2');
contentControl.SelectListItem('2');