<p>I am using a .NET Windows Forms DataGridView and I need to edit a DataBound column (that binds on a boolean DataTable column). For this I specify the cell template like this:</p>

<p>DataGridViewColumn column = new DataGridViewColumn(new DataGridViewCheckBoxCell());</p>

<p>You see that I need a CheckBox cell template.</p>

<p>The problem I face is that this column is constantly readonly/disabled, as if it would be of TextBox type. It doesn't show a checkbox at all.</p>

<p>Any thoughts on how to work with editable checkbox columns for DataGridView?</p>

<p>Update: For windows forms, please.</p>

<p>Thanks.</p>

[{'answer_id': 71252, 'author': 'Biri', 'author_id': 968, 'author_profile': 'https://Stackoverflow.com/users/968', 'pm_score': 0, 'selected': False, 'text': '<p>Create a TemplateField and bound the id to it, something like this:</p>\n\n<pre><code>&lt;asp:TemplateField HeaderText="Whatever" SortExpression="fieldname" ItemStyle-HorizontalAlign="Center"&gt;\n    &lt;ItemTemplate&gt;\n        &lt;asp:CheckBox runat="server" ID="rowCheck" key=\'&lt;%# Eval("id") %&gt;\' /&gt;\n    &lt;/ItemTemplate&gt;\n&lt;/asp:TemplateField&gt;\n</code></pre>\n'}, {'answer_id': 74298, 'author': 'Phillip Wells', 'author_id': 3012, 'author_profile': 'https://Stackoverflow.com/users/3012', 'pm_score': 1, 'selected': False, 'text': '<p>Instead of trying to create the column in code, click on the tiny arrow in a box at the top right of the DataGridView control, and select "Edit Columns..." from the menu that appears. In the dialog box, click the Add button, then choose the "Databound column" option and pick the boolean column you\'re binding to.</p>\n'}, {'answer_id': 81252, 'author': 'Vasile Tomoiaga', 'author_id': 2130892, 'author_profile': 'https://Stackoverflow.com/users/2130892', 'pm_score': 3, 'selected': False, 'text': '<p>Well, after more than 4 hours of debugging, I have found that the DataGridView row height was too small for the checkbox to be painted, so it was not displayed at all. I have found this after an accidental row height resizing.</p>\n\n<p>As a solution, you can set the AutoSizeRowsMode to AllCells.</p>\n\n<p><code>richDataGrid.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;</code></p>\n'}]
['https://Stackoverflow.com/questions/71226', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2130892/']