Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can display a check box in a cell using the check box cell. A check box cell displays a small check box that can have one of three states, checked, unchecked, or indeterminate. You can customize the check box by setting the text.
Set the isThreeState method to true to display three states instead of two (checked or unchecked). You can also specify the alignment of the check box and the text with the textAlign method.
Image Removed
You can set the state of the check box in code with the value method as shown in the following table:

Value

State

null

Indeterminate

0

Unchecked

1

Checked

Using Code
This example creates a check box cell with three states.你可以在单元格中显示一个复选框。

复选框有三种状态:勾选,未勾选,或者不定态。

你可以给复选框单元格设置文字。

使用 isThreeState 方法设置复选框单元格为双态(勾选或者未勾选)还是三态的(勾选,未勾选或者不定态)。

你也可以使用 textAlign 设置复选框单元格的对齐方式。


Image Added

你可以使用 value 方法设置复选框单元格的值,如下表:


对应的状态

null

不定态

0

未勾选

1

勾选


示例代码
以下代码创建了一个三态的复选框单元格:


JavaScript

Copy Code

var cellType = new GC.Spread.Sheets.CellTypes.CheckBox();cellType.caption("caption");cellType.textTrue("True");cellType.textFalse("False");cellType.textIndeterminate("Indeterminate");cellType.textAlign(GC.Spread.Sheets.CellTypes.CheckBoxTextAlign.bottom);cellType.isThreeState(true);activeSheet.getCell(1, 1).cellType(cellType);// activeSheet.getCell(1, 1).value(1);

 


See Also另见
CheckBoxTextAlign Enumeration
CheckBox class