How to pre-select a checkbox inside a WinForms Grid cell?
In order to pre-select the checkbox in a WinForms grid cell, CellValue can be used to set value for the CheckBox. It is depending upon the values of CheckBoxOptions.CheckedValue and CheckBoxOptions.UncheckedValue. Because these properties hold the values for selecting the checkbox.
Code Snippet
C#
//Sets the cell type as Checkbox. this.gridControl1[row, col].CellType = "CheckBox"; //Sets the Checked and Unchecked values for the checkbox. this.gridControl1[row, col].CheckBoxOptions.CheckedValue = "true"; this.gridControl1[row, col].CheckBoxOptions.UncheckedValue = "false"; //Sets the type of the cell value as bool. this.gridControl1[row, col].CellValueType = typeof(bool); //Sets the Cell value. this.gridControl1[row, col].CellValue = true;
VB
'Sets the cell type as Checkbox. Me.gridControl1(row, col).CellType = "CheckBox" 'Sets the Checked and Unchecked values for the checkbox. Me.gridControl1(row, col).CheckBoxOptions.CheckedValue = "true" Me.gridControl1(row, col).CheckBoxOptions.UncheckedValue = "false" 'Sets the type of the cell value as bool. Me.gridControl1(row, col).CellValueType = GetType(Boolean) 'Sets the Cell value. Me.gridControl1(row, col).CellValue = True
Screenshot
Sample Link:
Conclusion
I hope you enjoyed learning about how to pre-select a checkbox inside a WinForms Grid cell.
You can refer to our WinForms GridControl feature tour page to learn about its other groundbreaking feature representations. You can also explore ourdocumentation 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!