ApiContentControlList

new ApiContentControlList()

Class representing a list of values of the combo box / dropdown list content control.

Methods

Name Description
Add

Adds a new value to the combo box / dropdown list content control.

Clear

Clears a list of values of the combo box / dropdown list content control.

GetAllItems

Returns a collection of items (the ApiContentControlListEntry objects) of the combo box / dropdown list content control.

GetClassType

Returns a type of the ApiContentControlList class.

GetElementsCount

Returns a number of items of the combo box / dropdown list content control.

GetItem

Returns an item of the combo box / dropdown list content control by the position specified in the request.

GetParent

Returns a parent of the combo box / dropdown list content control.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
Api.pluginMethod_AddContentControlList(1, [{Display: "Item1_D", Value: "Item1_V"}, {Display: "Item2_D", Value: "Item2_V"}], {"Id": 100, "Tag": "CC_Tag", "Lock": 3});
var aContentControls = oDocument.GetAllContentControls();
var oContentControlList = aContentControls[0].GetDropdownList();
oContentControlList.Add("Item3_D", "Item3_V", 2);
oDocument.AddElement(0, oContentControlList);
var sType = oContentControlList.GetClassType();
var oParagraph = Api.CreateParagraph();
oParagraph.AddText("Class type: " + sType);
oDocument.Push(oParagraph);
var oContentControl = oContentControlList.GetParent();
oParagraph = Api.CreateParagraph();
sType = oContentControl.GetClassType();
oParagraph.AddText("The class type of the combo box parent element: " + sType);
oDocument.Push(oParagraph);
var nItems = oContentControlList.GetElementsCount();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Number of elements in the combo box: " + nItems);
oDocument.Push(oParagraph);
var oItem = oContentControlList.GetItem(0);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The first item from the combo box: " + oItem.GetText());
oDocument.Push(oParagraph);
var aItems = oContentControlList.GetAllItems();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The second item from the combo box: " + aItems[1].GetText());
oDocument.Push(oParagraph);
builder.SaveFile("docx", "ApiContentControlList.docx");
builder.CloseFile();

Resulting document