Home › Forums › WinForms controls › Xceed Grid for WinForms › Adding Check Box For Unbound Column for NON boolean Data type in Xceed Grid Version 2.2 › Reply To: Adding Check Box For Unbound Column for NON boolean Data type in Xceed Grid Version 2.2
You don’t have to add a complex object to the grid. Just adding a boolean would get the checkbox in place in the grid.
To set the column to boolean, add a column using the designer. To set the type, hover the column name in the designer and right-click when you have the column icon selected (a black vertical bar followed by a grey vertical bar), select properties, select DataType, select System.Boolean.
If you don’t want to set the column to a boolean type for every rows it contains, you will have to add each row manually (programmatically) and set a viewer and a manager for each of these rows. You can check out our RichCellEditors sample application, for this matter.
In the end, your code should look like:
dataRow = gridControl1.DataRows.AddNew();
dataRow.Cells[ “ColName” ].Value = “Married”;
dataRow.Cells[ “ColValue” ].HorizontalAlignment = HorizontalAlignment.Center;
dataRow.Cells[ “ColValue” ].VerticalAlignment = VerticalAlignment.Center;
dataRow.Cells[ “ColValue” ].CellEditorManager = new CheckBoxEditor();
dataRow.Cells[ “ColValue” ].CellViewerManager = new CheckBoxViewer();
dataRow.Cells[ “ColValue” ].Value = false;
Imported from legacy forums. Posted by Ghislain (had 1127 views)