Skip to main content

GetElement

Returns an element of the current inline text content control using the position specified.

Syntax

expression.GetElement(nPos);

expression - A variable that represents a ApiInlineLvlSdt class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nPosRequirednumberThe position where the element which content we want to get must be located.

Returns

ParagraphContent

Example

Get an element of the inline text content control using the position specified in a document.

// Get the element of the inline text control, make it bold in a document.

// How to get the n^th element of the inline control in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let inlineLvlSdt = Api.CreateInlineLvlSdt();
paragraph.AddInlineLvlSdt(inlineLvlSdt);
for (let i = 0; i < 10; ++i) {
let run = Api.CreateRun();
run.AddText("This is text run " + (i + 1) + ". ");
inlineLvlSdt.AddElement(run);
}
let changeRun = inlineLvlSdt.GetElement(4);
changeRun.SetBold(true);
paragraph.AddLineBreak();
paragraph.AddLineBreak();
paragraph.AddLineBreak();
paragraph.AddText("We added 10 text runs to the above inline text content control. Then we changed the fifth run, so it is different from the others.");