跳到主要内容

SetChecked

选中当前复选框。

语法

expression.SetChecked(isChecked);

expression - 表示 ApiCheckBoxForm 类的变量。

参数

名称必需/可选数据类型默认值描述
isChecked必需boolean指定当前复选框是否被选中(true)或未选中(false)。

返回值

boolean

示例

此示例选中复选框。

// How to check a form.

// Check a checkbox.

let doc = Api.GetDocument();
let checkBoxForm = Api.CreateCheckBoxForm({"key": "Marital status", "tip": "Specify your marital status", "required": true, "placeholder": "Marital status", "radio": true});
let paragraph = doc.GetElement(0);
paragraph.AddElement(checkBoxForm);
paragraph.AddText(" Married");
paragraph.AddLineBreak();
checkBoxForm = Api.CreateCheckBoxForm({"key": "Marital status", "tip": "Specify your marital status", "required": true, "placeholder": "Marital status", "radio": true});
paragraph.AddElement(checkBoxForm);
paragraph.AddText(" Single");
checkBoxForm.SetChecked(true);