4 Replies - 348 Views - Last Post: 24 April 2014 - 09:21 PM Rate Topic: -----

#1 suzu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-January 14

[Help] DataGridView CheckBoxColumn

Posted 24 April 2014 - 09:23 AM

I cannot check the checkbox in my datagridview.

Here is my code.

First, I added a checkbox column.
        private void addCheckBoxColumn()
        {
            DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
            checkColumn.Name = "clmCheck";
            checkColumn.HeaderText = "";
            checkColumn.Width = 100;
            checkColumn.ReadOnly = false;
            dgv1.Columns.Add(checkColumn);
        }


Next I populate the datagridview.
                com.CommandText = @"SELECT Name FROM USER";
                SqlDataAdapter adapter = new SqlDataAdapter(com);
                table = new DataTable("USER");
                adapter.Fill(table);
                dgv1.DataSource = table;



Is This A Good Question/Topic? 0
  • +

Replies To: [Help] DataGridView CheckBoxColumn

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4436
  • View blog
  • Posts: 7,707
  • Joined: 08-June 10

Re: [Help] DataGridView CheckBoxColumn

Posted 24 April 2014 - 09:35 AM

...And? What does happen? An error? Nothing? What's supposed to happen? Is the column supposed to be checked from code, or by the user?

Please give us all the information we need to help. Otherwise we're all just wasting time.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3222
  • View blog
  • Posts: 10,810
  • Joined: 12-December 12

Re: [Help] DataGridView CheckBoxColumn

Posted 24 April 2014 - 09:35 AM

You need to set the DataPropertyName of the checkbox-column to the field-name.

If the field is 'Name' though, then is it a boolean (yes/no) field?
Was This Post Helpful? 0
  • +
  • -

#4 suzu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-January 14

Re: [Help] DataGridView CheckBoxColumn

Posted 24 April 2014 - 08:13 PM

View PostCurtis Rutland, on 24 April 2014 - 09:35 AM, said:

...And? What does happen? An error? Nothing? What's supposed to happen? Is the column supposed to be checked from code, or by the user?

Please give us all the information we need to help. Otherwise we're all just wasting time.


The column is supposed to be checked by the user. Nothing happens.
Was This Post Helpful? 0
  • +
  • -

#5 suzu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 25-January 14

Re: [Help] DataGridView CheckBoxColumn

Posted 24 April 2014 - 09:21 PM

My bad, I forgot to check "enable editing"
LOL

Thread Closed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1