Get Started
Usage API

ApiInlineLvlSdt

new ApiInlineLvlSdt()

Class represent a container for the elements of a paragraph

Methods

Name Description
AddElement

Add an element to the inline text content control.

AddText

Adds text to the current content control.

Copy

Create a copy of the inline content control. Ingonore comments, footnote references, complex fields

Delete

Removes content control and content. If keepContent is true, the content is not deleted.

GetAlias

Get the alias attribute for this container

GetClassType

Get the type of this class.

GetElement

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

GetElementsCount

Get the number of elements in the current inline text content control. The text content control is created with one text run present in it by default, so any even without any element added this method will return the value of '1'.

GetLabel

Get the label attribute for this container

GetLock

Get the lock type of this container

GetParentContentControl

Gets the content control that contains the current content control.

GetParentTable

Gets the table that contains the content control.

GetParentTableCell

Gets the table cell that contains the content control.

GetRange

Returns a Range object that represents the part of the document contained in the specified content control.

GetTag

Get the tag attribute for this container

Push

Add an element to the end of inline text content control.

RemoveAllElements

Remove all the elements from the current inline text content control.

RemoveElement

Remove the element using the position specified from the current inline text content control.

SetAlias

Set the alias attribute for this container

SetLabel

Add a string label to the current inline text content control.

SetLock

Set the lock to the current inline text content control. "contentLocked" - content cannot be edited "sdtContentLocked" - content cannot be edited and BlockLvlSdt cannot be deleted. "sdtLocked" - BlockLvlSdt cannot be deleted.

SetTag

Add a string tag to the current inline text content control.

SetTextPr

Applies text settings to content of content control.

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph = oDocument.GetElement(0);
oInlineLvlSdt = Api.CreateInlineLvlSdt();
oRun = Api.CreateRun();
oRun.AddText("This is an inline text content control.");
oInlineLvlSdt.AddElement(oRun, 0);
changeRun = oInlineLvlSdt.GetElement(0);
changeRun.SetBold(true);
oParagraph.AddInlineLvlSdt(oInlineLvlSdt);
oInlineLvlSdt.SetAlias("№1");
oAlias = oInlineLvlSdt.GetAlias();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Alias: " + oAlias);
oDocument.Push(oParagraph);
oInlineLvlSdt.SetLabel("2147483647");
oLabel = oInlineLvlSdt.GetLabel();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Label: " + oLabel);
oDocument.Push(oParagraph);
oInlineLvlSdt.SetTag("This is a tag");
oTag = oInlineLvlSdt.GetTag();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Tag: " + oTag);
oDocument.Push(oParagraph);
oInlineLvlSdt.SetLock("contentLocked");
oLock = oInlineLvlSdt.GetLock();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Lock type: " + oLock);
oDocument.Push(oParagraph);
oClassType = oInlineLvlSdt.GetClassType();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Class Type = " + oClassType);
oDocument.Push(oParagraph);
builder.SaveFile("docx", "ApiInlineLvlSdt.docx");
builder.CloseFile();

Resulting document