Skip to main content

SetBackgroundColor

Sets the background color to the current content control.

Syntax

expression.SetBackgroundColor(color);

expression - A variable that represents a ApiBlockLvlSdt class.

Parameters

NameRequired/OptionalData typeDefaultDescription
colorOptionalApiColorThe background color.

Returns

boolean

Example

Set a background color on a content control in a document.

// How do I change the background color of a content control in a document?

// Highlight a content control with a colored background to make it stand out in a document.

let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
blockLvlSdt.SetBackgroundColor(Api.RGBA(0, 0, 255, 40));
blockLvlSdt.GetContent().GetElement(0).AddText("This is a block text content control with a blue transparent background.");
doc.AddElement(0, blockLvlSdt);