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. Visual Basic
  4. Add Checkbox to DataGridView at code behind.

Add Checkbox to DataGridView at code behind.

Scheduled Pinned Locked Moved Visual Basic
questionwpfwcf
4 Posts 3 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.
  • C Offline
    C Offline
    cheeken2u
    wrote on last edited by
    #1

    I have a datagridview to show data. My datagridview is using datasource to binding data. Now my question is , How can i add a new column as checkbox in front of each row? ( means if i have 3 row of record, each row will have one check box ) and store a value to it ? and how i check this checkbox is checked or unchecked ? thanks.

    Best regards, Chee ken

    M 1 Reply Last reply
    0
    • C cheeken2u

      I have a datagridview to show data. My datagridview is using datasource to binding data. Now my question is , How can i add a new column as checkbox in front of each row? ( means if i have 3 row of record, each row will have one check box ) and store a value to it ? and how i check this checkbox is checked or unchecked ? thanks.

      Best regards, Chee ken

      M Offline
      M Offline
      Marcus J Smith
      wrote on last edited by
      #2

      You should add the checkbox to the datagrid as a template column. Then you will basically step through the datagrid looking to see if the control exists based on the ID you gave it in the template column and then DirectCast(item, Checkbox) and see if it is .Checked = True or not. I hope that helps. Cleako

      P 1 Reply Last reply
      0
      • M Marcus J Smith

        You should add the checkbox to the datagrid as a template column. Then you will basically step through the datagrid looking to see if the control exists based on the ID you gave it in the template column and then DirectCast(item, Checkbox) and see if it is .Checked = True or not. I hope that helps. Cleako

        P Offline
        P Offline
        priya_p233
        wrote on last edited by
        #3

        hi, i wnt to write code that shuld be executed when user clicks on checkbox that is present as datagrid columne. where should i write the code.

        priya

        M 1 Reply Last reply
        0
        • P priya_p233

          hi, i wnt to write code that shuld be executed when user clicks on checkbox that is present as datagrid columne. where should i write the code.

          priya

          M Offline
          M Offline
          Marcus J Smith
          wrote on last edited by
          #4

          Since you are changing the topic you should start your own thread. BUT, you just need to set a function name to be called in the OnClick event of the template column's checkbox. That function should be Protected instead of Private.


          Cleako

          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