Hello,
I am trying to add a listBox and checkBox to different columns on a DataGridView control.
1.The DataGridView control is bount to a dataset which is filled from a SQL table
2. I am able to display a Checkbox on the DataGridView control with this code:
DataGridViewCheckBoxColumn
cb = new DataGridViewCheckBoxColumn
();
dataGridView1.Columns.Inse
rt(25, cb);
cb.HeaderText = "Couln 26?";
3. I am not able to bind the checkbox to an actual datarow in the datatable of the dataset.
This is my code so far:
Conn = new OleDbConnection(ConStr))
{
using (cmd = new OleDbCommand(SQL, Conn))
{
Conn.Open();
da = new OleDbDataAdapter()
da.SelectCommand = cmd;
oleDbCb = new OleDbCommandBuilder(da)
//*****clear the dataset of all old records before loading it again!!!!! ****
dataSet1.Clear();
da.Fill(dataSet1, "Stats");
dataGridView1.DataSource = dataSet1;
dataGridView1.DataMember = "Stats";
//new Checb
DataGridViewCheckBoxColumn
cb = new DataGridViewCheckBoxColumn
();
dataGridView1.Columns.Inse
rt(25, cb);
cb.HeaderText = "Hail Given?";
I thought there might be an index method to call from cb to assign the correct row to the check box object but couldn't make it work.
Does anyone know how to do this?
Thanks!!
Start Free Trial