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. DataGrid Checkbox Event capture

DataGrid Checkbox Event capture

Scheduled Pinned Locked Moved C#
csharphelpquestion
4 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.
  • R Offline
    R Offline
    Ruchi Gupta
    wrote on last edited by
    #1

    Hi All, I have a C# Windows Form, which contains a DataGrid, and one of the column in the DaatrGrid is Checkbox. What I need to do is - when checkbox is checked, all other checkboxes should be unchecked. For ex: if there are 10 rows in DataGrid, and Row - 2 has checkbox checked. Now when "Checkbox column of Row - 5" is clicked, it should un-check "Checkbox column of Row - 2" . Please let me know how can I capture check_event and loop through all rows. Any help or pointers :confused: Thanks in Advance :rolleyes: Ruchi

    H 2 Replies Last reply
    0
    • R Ruchi Gupta

      Hi All, I have a C# Windows Form, which contains a DataGrid, and one of the column in the DaatrGrid is Checkbox. What I need to do is - when checkbox is checked, all other checkboxes should be unchecked. For ex: if there are 10 rows in DataGrid, and Row - 2 has checkbox checked. Now when "Checkbox column of Row - 5" is clicked, it should un-check "Checkbox column of Row - 2" . Please let me know how can I capture check_event and loop through all rows. Any help or pointers :confused: Thanks in Advance :rolleyes: Ruchi

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Actually, it's not a CheckBox. A check box is merely drawn by the DataGridBoolColumn using either ControlPaint.DrawMixedCheckBox or ControlPaint.DrawCheckBox, depending on whether or not the column allows nulls (DBNull). If you want to use an actual CheckBox and expose the event (better to encapsulate the CheckBox and expose only what's needed), you'll have to derive your own DataGridColumnStyle. See the documentation for that class in the .NET Framework SDK, which also includes a sample using a DateTimePicker control.

      Microsoft MVP, Visual C# My Articles

      1 Reply Last reply
      0
      • R Ruchi Gupta

        Hi All, I have a C# Windows Form, which contains a DataGrid, and one of the column in the DaatrGrid is Checkbox. What I need to do is - when checkbox is checked, all other checkboxes should be unchecked. For ex: if there are 10 rows in DataGrid, and Row - 2 has checkbox checked. Now when "Checkbox column of Row - 5" is clicked, it should un-check "Checkbox column of Row - 2" . Please let me know how can I capture check_event and loop through all rows. Any help or pointers :confused: Thanks in Advance :rolleyes: Ruchi

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        Oh, I almost forgot: if you're using a DataSet or DataTable for binding, you can handle the DataTable.ColumnChanging or DataTable.ColumnChangeed event and then enumerate the DataRows in the `DataTable` and change what you need accordingly. Microsoft MVP, Visual C# [My Articles](http://www.codeproject.com/script/articles/list_articles.asp?userid=46969)

        R 1 Reply Last reply
        0
        • H Heath Stewart

          Oh, I almost forgot: if you're using a DataSet or DataTable for binding, you can handle the DataTable.ColumnChanging or DataTable.ColumnChangeed event and then enumerate the DataRows in the `DataTable` and change what you need accordingly. Microsoft MVP, Visual C# [My Articles](http://www.codeproject.com/script/articles/list_articles.asp?userid=46969)

          R Offline
          R Offline
          Ruchi Gupta
          wrote on last edited by
          #4

          Thanks so much for your response. I will work towards this pointer Ruchi:|

          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