>>private void _AddRow() >>{ >> if (dsGrid.Tables.Count == 0) >> { >> 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)); // The checkbox column >> >> dsGrid.Tables.Add(table); >> >> grdData.DataMember = dsGrid.Tables[0].TableName; >> grdData.DataSource = dsGrid.Tables[0]; >> } >> >> DataRow NewRow = dsGrid.Tables[0].NewRow(); >> NewRow["QueryId"] = _QueryId; >> dsGrid.Tables[0].Rows.Add(NewRow); >>} >>>Just tried this. Firstly is looks as if a bool value will default to using a DataGridViewCheckBox automatically..
protected override void OnLoad(EventArgs e) > { > DataSet dsGrid = new DataSet(); > if (dsGrid.Tables.Count == 0) > { > 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)); // The checkbox column > > dsGrid.Tables.Add(table); > > grdData.DataMember = dsGrid.Tables[0].TableName; > grdData.DataSource = dsGrid.Tables[0]; > } > > DataRow NewRow = dsGrid.Tables[0].NewRow(); > NewRow["QueryId"] = 5; > dsGrid.Tables[0].Rows.Add(NewRow); > }(only change is creating a DataSet and changing the "QueryId" to a concrete value.) Only action in the designer was dropping a DataGridView on the Form and setting the Name. Does this work for you?