Get Started
Usage API
More information

SetLock

SetLock(sLockType)

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.

Parameters:

Name Type Description
sLockType "contentLocked" | "sdtContentLocked" | "sdtLocked"

The type of the lock applied to the inline text content control.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oBlockLvlSdt = Api.CreateBlockLvlSdt();
oBlockLvlSdt.GetContent().GetElement(0).AddText("This is a block text content control with the content lock set to it.");
oBlockLvlSdt.SetLock("sdtContentLocked");
oDocument.AddElement(0, oBlockLvlSdt);
oLock = oBlockLvlSdt.GetLock();
oParagraph = oDocument.GetElement(1);
oParagraph.AddText("Lock type: " + oLock);
builder.SaveFile("docx", "SetLock.docx");
builder.CloseFile();

Resulting document