跳到主要内容

GetBackgroundColor

返回当前内容控件的背景颜色。

语法

expression.GetBackgroundColor();

expression - 表示 ApiBlockLvlSdt 类的变量。

参数

此方法没有任何参数。

返回值

ApiColor

示例

读取文档中内容控件的背景颜色。

// How do I get the background color set on a content control in a document?

// Check what background color a content control has and display its hex value in a document.

let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
blockLvlSdt.SetBackgroundColor(Api.RGBA(200, 200, 255, 255));
let color = blockLvlSdt.GetBackgroundColor();
blockLvlSdt.GetContent().GetElement(0).AddText("BackgroundColor: " + (color ? color.GetHex() : "none"));
doc.AddElement(0, blockLvlSdt);

blockLvlSdt = Api.CreateBlockLvlSdt();
color = blockLvlSdt.GetBackgroundColor();
blockLvlSdt.GetContent().GetElement(0).AddText("BackgroundColor: " + (color ? color.GetHex() : "none"));
doc.AddElement(1, blockLvlSdt);