[]
Checkbox cell adds a checkbox to the cell, allowing users to toggle options.
To create a checkbox in a cell, use the CheckBoxCellType class in the GrapeCity.Wpf.SpreadSheet.CellType namespace. Use Content property to display text in a checkbox. Additionally, the TrueContent, FalseContent, and IndeterminateContent properties allows you to customize text based on the checkbox state. If you want to display all three states; checked, unchecked, and Indeterminate, set the IsThreeState property to True.
Similar to Button cells, checkbox cells support command execution, where clicking the checkbox triggers a command. For this functionality, use the properties of the CellCommandParameter class. The available properties are listed in the table below.
Property | Description |
---|---|
Column | Gets the column of the checkbox that is clicked. |
Row | Gets the row of the checkbox that is clicked. |
CustomCommandParameter | Gets or sets the parameters to pass to the command. |
Worksheet | Gets the worksheet of the checkbox that is clicked. |
Refer to the following example code to set data template with the IsThreeState property.
XAML
<Grid>
<gss:GcSpreadSheet x:Name ="spreadSheet1" HorizontalAlignment ="Stretch" VerticalAlignment ="Stretch" >
<gss:GcSpreadSheet.Sheets>
<gss:SheetInfo ColumnCount ="20" RowCount ="50" >
<gss:SheetInfo.Columns >
<gss:ColumnInfo Width ="180">
<gss:ColumnInfo.CellType>
<CT:CheckBoxCellType IsThreeState ="True" FalseContent ="Reject" TrueContent ="Approval" IndeterminateContent ="Pending"/>
</gss:ColumnInfo.CellType >
</gss:ColumnInfo>
</gss:SheetInfo.Columns>
</gss:SheetInfo>
</gss:GcSpreadSheet.Sheets>
</gss:GcSpreadSheet>
</Grid>
C#
// CheckBoxCellType.
CheckBoxCellType cb = new CheckBoxCellType();
cb.IsThreeState = true;
cb.IndeterminateContent = "Indeterminate";
cb.FalseContent = "Rejected";
cb.TrueContent = "Approved";
spreadSheet1.Workbook.ActiveSheet.Columns[0].CellType = cb;
VB
' CheckBoxCellType.
Dim cb As CheckBoxCellType = New CheckBoxCellType()
cb.IsThreeState = True
cb.IndeterminateContent = "Indeterminate"
cb.FalseContent = "Rejected"
cb.TrueContent = "Approved"
spreadSheet1.Workbook.ActiveSheet.Columns(0).CellType = cb