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. datagridview checkbox problem [modified]

datagridview checkbox problem [modified]

Scheduled Pinned Locked Moved C#
help
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.
  • V Offline
    V Offline
    Varun Sareen
    wrote on last edited by
    #1

    Dear Friends, I have a datagridview in which there is parent child relationship in rows. I want that If a parent row is checked in the datagrid and any child node corresponding to it is checked then if the user tries to uncheck the Parent Row then the Parent row shouldn't gets uncheck and remains checked. I have tried to write the code for the same on CELLCONTENTCLICK event and on the CELLVALUECHANGEDEVENT but all in vain :(. Any kind of help will be appreciable. Thanks

    Varun Sareen (Dot Net Developer)

    modified on Wednesday, December 22, 2010 2:02 AM

    H G 2 Replies Last reply
    0
    • V Varun Sareen

      Dear Friends, I have a datagridview in which there is parent child relationship in rows. I want that If a parent row is checked in the datagrid and any child node corresponding to it is checked then if the user tries to uncheck the Parent Row then the Parent row shouldn't gets uncheck and remains checked. I have tried to write the code for the same on CELLCONTENTCLICK event and on the CELLVALUECHANGEDEVENT but all in vain :(. Any kind of help will be appreciable. Thanks

      Varun Sareen (Dot Net Developer)

      modified on Wednesday, December 22, 2010 2:02 AM

      H Offline
      H Offline
      Hiren solanki
      wrote on last edited by
      #2

      Varun Sareen wrote:

      I have a datagridview in which there is parent child relationship in rows. If a parent row is checked in the datagrid and any child node corresponding to it is checked then if the user tries to uncheck the Parent Row then that row doesn't gets uncheck and it again gets checked on itself.

      Just keep toggling, I mean

      If(checked)
      uncheck;
      else
      check;

      Regards, Hiren.

      My Recent Article: - Way to know which control have raised a postback
      My Recent Tip/Trick: - Remove HTML Tag, get plain Text

      V 1 Reply Last reply
      0
      • H Hiren solanki

        Varun Sareen wrote:

        I have a datagridview in which there is parent child relationship in rows. If a parent row is checked in the datagrid and any child node corresponding to it is checked then if the user tries to uncheck the Parent Row then that row doesn't gets uncheck and it again gets checked on itself.

        Just keep toggling, I mean

        If(checked)
        uncheck;
        else
        check;

        Regards, Hiren.

        My Recent Article: - Way to know which control have raised a postback
        My Recent Tip/Trick: - Remove HTML Tag, get plain Text

        V Offline
        V Offline
        Varun Sareen
        wrote on last edited by
        #3

        Thanks Hiren, for an immediate reply but i am sorry to say that I actually asked the wrong question (there was a little grammar mistake that made the question meaning other way around). Now I have corrected the question so now if you could look into it and provide me with some answer then that would be appreciable. Thanks

        Varun Sareen (Dot Net Developer)

        modified on Wednesday, December 22, 2010 4:21 AM

        1 Reply Last reply
        0
        • V Varun Sareen

          Dear Friends, I have a datagridview in which there is parent child relationship in rows. I want that If a parent row is checked in the datagrid and any child node corresponding to it is checked then if the user tries to uncheck the Parent Row then the Parent row shouldn't gets uncheck and remains checked. I have tried to write the code for the same on CELLCONTENTCLICK event and on the CELLVALUECHANGEDEVENT but all in vain :(. Any kind of help will be appreciable. Thanks

          Varun Sareen (Dot Net Developer)

          modified on Wednesday, December 22, 2010 2:02 AM

          G Offline
          G Offline
          GenJerDan
          wrote on last edited by
          #4

          No clue off the top of my head how to do it, but... Look for some treeview examples that have tri-state checkboxes (they do pretty much what you want to do in your gridview...sort of). You may get some ideas looking at how they do it. (It's going to wind up being a matter of getting all the children and seeing if they're checked before dealing with the parent)

          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