Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Checkboxes in datagridview

Checkboxes in datagridview

Scheduled Pinned Locked Moved C#
question
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    akkram
    wrote on last edited by
    #1

    Hi, I have an unbound DataGridView which I have added two columns to (in the designer): one DataGridViewTextBoxColumn and one DataGridViewCheckBoxColumn. Now I want to add rows to the DataGridView and be able to check and uncheck the cells under the DataGridViewCheckBoxColumn. I use the following code to add a new row but I can't get it to work. int rowIndex = myDataGridView.Rows.Add(); DataGridViewRow row = myDataGridView.Rows[rowIndex]; row.Cells["columnText"].Value = "some text"; row.Cells["columnCheckBox"].Value = true; Anyone knows how I can get this to work? /thanks

    H 1 Reply Last reply
    0
    • A akkram

      Hi, I have an unbound DataGridView which I have added two columns to (in the designer): one DataGridViewTextBoxColumn and one DataGridViewCheckBoxColumn. Now I want to add rows to the DataGridView and be able to check and uncheck the cells under the DataGridViewCheckBoxColumn. I use the following code to add a new row but I can't get it to work. int rowIndex = myDataGridView.Rows.Add(); DataGridViewRow row = myDataGridView.Rows[rowIndex]; row.Cells["columnText"].Value = "some text"; row.Cells["columnCheckBox"].Value = true; Anyone knows how I can get this to work? /thanks

      H Offline
      H Offline
      half life
      wrote on last edited by
      #2

      First Of all thay "Nice" to add rows or handle them : Object[] Row = { false }; dataGridView1.Rows.Add(Row); Just Set the Propery of Enable Editing Adn Thats it :)

      Have Fun Never forget it

      A 2 Replies Last reply
      0
      • H half life

        First Of all thay "Nice" to add rows or handle them : Object[] Row = { false }; dataGridView1.Rows.Add(Row); Just Set the Propery of Enable Editing Adn Thats it :)

        Have Fun Never forget it

        A Offline
        A Offline
        akkram
        wrote on last edited by
        #3

        Sorry but I don't get it..

        H 1 Reply Last reply
        0
        • H half life

          First Of all thay "Nice" to add rows or handle them : Object[] Row = { false }; dataGridView1.Rows.Add(Row); Just Set the Propery of Enable Editing Adn Thats it :)

          Have Fun Never forget it

          A Offline
          A Offline
          akkram
          wrote on last edited by
          #4

          Figured it out, thx :)

          1 Reply Last reply
          0
          • A akkram

            Sorry but I don't get it..

            H Offline
            H Offline
            half life
            wrote on last edited by
            #5

            When U Add A DataGridViewColumn See That The Enable Edting Property is Set To True Then To Add Rows Do THis : value toCol1Row1 = .... value toCol2Row1 = .... value toCol3Row1 = .... Where value ( int, string...) Gather all of the Variables to an Object array Object [] Row1 = {toCol1Row1 ,toCol2Row1 ,toCol3Row1 }; Add it to the DataGrdiView DataGrdiView.Rows.Add(Row1); While in your App u need to set the value of the CheckBox Column to either true/false bool toCheckBoxColumn = true; Object [] Row1 = {... ,toCheckBoxColumn ,... };

            Have Fun Never forget it

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups