I' ve found that in VS 2008 anyway the DGV autogenerates checkbox columns for boolean columns when bound to a strongly typed dataset with no problem.
>Judging from the code you've posted, it looks to me like you're letting the grid AutoGenerate its own columns? You might be better off setting that up yourself. Like Viv mentioned, you really need to have the column that represents the boolean value be a DataGridViewCheckBoxColumn, which I don't believe will be AutoGenerated. Do it in the designer (when you add a new column in the designer, you choose the type in that dialog).
>
>~~Bonnie
>
>
>
>
>>Here it is. A few column name changes from below, but otherwise the same:
>>
>>
>>DataTable table = new DataTable();
>>table.Columns.Add("ColumnId", typeof(int));
>>table.Columns.Add("QueryId", typeof(int));
>>table.Columns.Add("TableId", typeof(int));
>>table.Columns.Add("TableName", typeof(string));
>>table.Columns.Add("ApexColumnName", typeof(string));
>>table.Columns.Add("Expression", typeof(string));
>>table.Columns.Add("GroupBy", typeof(bool));
>>
>>dsGrid.Tables.Add(table);
>>
>>grdData.DataMember = dsGrid.Tables[0].TableName;
>>grdData.DataSource = dsGrid.Tables[0];
>>
>>grdData.Columns["ColumnId"].Visible = false;
>>grdData.Columns["QueryId"].Visible = false;
>>grdData.Columns["TableId"].Visible = false;
>>grdData.Columns["TableName"].Width = 200;
>>grdData.Columns["ApexColumnName"].Width = 200;
>>grdData.Columns["Expression"].Width = 290;
>>
>>grdData.Columns["ApexColumnName"].HeaderText = "Apex Column Name";
>>grdData.Columns["GroupBy"].HeaderText = "Group By";
>>grdData.Columns["GroupBy"].ReadOnly = false;
>>grdData.Columns["GroupBy"].CellTemplate = new DataGridViewCheckBoxCell();
>>
>>
>>
>>
>>
>>>Can you post your code ?
>>>>I tried it. No change.
>>>>
>>>>
>>>>
>>>>>
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcheckboxcolumn.aspx>>>>>Not sure how you can use this if you're letting the table dictate the grid columns tho.......
>>>>>
>>>>>>I'm not. how do I?
>>>>>>
>>>>>>>Where are you setting the column type to DataGridViewCheckBoxColumn ?
>>>>>>>
>>>>>>>>Why is it so blasted difficult to add controls in DataGridView columns??? I gave up trying to add a combo. Now I would like to add a checkbox column.
>>>>>>>>
>>>>>>>>Anway... I am creating the data table that is bound to the grid in code:
>>>>>>>>
>>>>>>>>
>>>>>>>>DataTable table = new DataTable();
>>>>>>>>table.Columns.Add("ColumnId", typeof(int));
>>>>>>>>table.Columns.Add("QueryId", typeof(int));
>>>>>>>>table.Columns.Add("TableId", typeof(int));
>>>>>>>>table.Columns.Add("TableName", typeof(string));
>>>>>>>>table.Columns.Add("ApexColumnName", typeof(string));
>>>>>>>>table.Columns.Add("Expression", typeof(string));
>>>>>>>>table.Columns.Add("MyCheckBox", typeof(bool));
>>>>>>>>
>>>>>>>>dsGrid.Tables.Add(table);
>>>>>>>>
>>>>>>>>grdData.DataMember = dsGrid.Tables[0].TableName;
>>>>>>>>grdData.DataSource = dsGrid.Tables[0];
>>>>>>>>
>>>>>>>>grdData.Columns["ColumnId"].Visible = false;
>>>>>>>>grdData.Columns["QueryId"].Visible = false;
>>>>>>>>grdData.Columns["TableId"].Visible = false;
>>>>>>>>grdData.Columns["TableName"].Width = 200;
>>>>>>>>grdData.Columns["ApexColumnName"].Width = 200;
>>>>>>>>grdData.Columns["Expression"].Width = 290;
>>>>>>>>
>>>>>>>>
>>>>>>>>Notice the 'MyCheckBox' column. This created the CheckBox column in the grid, but when I click it, nothinghappens. No checkmark appears.
>>>>>>>>
>>>>>>>>What is wrong here????
Charles Hankey
Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy
Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.
-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin
Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.