How to pre-select a checkbox inside a WinForms Grid cell?
In WinForms GridControl, to pre-select (check) a checkbox in a grid cell, set the cell’s CellValue property to the appropriate value. The checked or unchecked state of the checkbox depends on the values assigned to the CheckBoxOptions.CheckedValue and CheckBoxOptions.UncheckedValue properties. These properties define which underlying values correspond to the checked and unchecked states of the checkbox in the grid cell.
C#
this.gridControl1[i, 3].CellType = "CheckBox";
//Set Checked and Unchecked values
this.gridControl1[i, 3].CheckBoxOptions.CheckedValue = "true";
this.gridControl1[i, 3].CheckBoxOptions.UncheckedValue = "false";
//Set the cell value type to Boolean
this.gridControl1[i, 3].CellValueType = typeof(bool);
//Set the default value to checked
this.gridControl1[i, 3].CellValue = true;
Me.GridControl1(i, 3).CellType = "CheckBox"
' Set Checked and Unchecked values
Me.GridControl1(i, 3).CheckBoxOptions.CheckedValue = "true"
Me.GridControl1(i, 3).CheckBoxOptions.UncheckedValue = "false"
' Set the cell value type to Boolean
Me.GridControl1(i, 3).CellValueType = GetType(Boolean)
' Set the default value to checked
Me.GridControl1(i, 3).CellValue = True
Conclusion
I hope you enjoyed
learning about how to achieve Excel-like text alignment in GridControl.
You can refer to our WinForms GridControl feature
tour page to learn about its other groundbreaking feature
representations. You can also explore our documentation to understand how to create and
manipulate data.
For current customers, you can check out our components from
the License
and Downloads page. If you are new to Syncfusion, you can try
our 30-day free
trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the
comments section below. You can also contact us through our support forums, Direct-Trac,
or feedback portal. We are always happy to assist you!