Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CheckBox In DataGridView
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01441085
Message ID:
01441101
Views:
29
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????
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform