Skip to main content

RemoveAllElements

Clears the contents from the current content control.

Syntax

expression.RemoveAllElements();

expression - A variable that represents a ApiBlockLvlSdt class.

Parameters

This method doesn't have any parameters.

Returns

boolean

Example

Clear all content from a content control in a document.

// How do I remove all content from a content control in a document?

// Empty a content control to start fresh with no paragraphs or text inside it in a document.

let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
blockLvlSdt.GetContent().GetElement(0).AddText("This is a block text content control.");
doc.AddElement(0, blockLvlSdt);
blockLvlSdt.RemoveAllElements();
let paragraph = doc.GetElement(1);
paragraph.AddText("All elements were removed from the content control.");