Advertisement

08.23.2007 at 05:56AM PDT, ID: 22782017
[x]
Attachment Details

Inserting a listBox and checkBox controls in DataGridView columns?

Asked by Saxitalis in Microsoft Visual C#.Net, C# Programming Language, Visual Studio .NET 2005

Tags: datagridview, checkbox, listbox

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.Insert(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.Insert(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
[+][-]08.23.2007 at 06:09AM PDT, ID: 19753941

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, C# Programming Language, Visual Studio .NET 2005
Tags: datagridview, checkbox, listbox
Sign Up Now!
Solution Provided By: RaisinJ
Participating Experts: 2
Solution Grade: B
 
 
[+][-]08.23.2007 at 09:21AM PDT, ID: 19755713

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]08.25.2007 at 05:37PM PDT, ID: 19769646

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628