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. Set checked state on all selected rows in datagridview

Set checked state on all selected rows in datagridview

Scheduled Pinned Locked Moved C#
helpquestion
3 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.
  • H Offline
    H Offline
    hakonvik
    wrote on last edited by
    #1

    I'm struggling to get this to work.. Is it possible to set the checked state on all the selected rows in an datagridview at the same time (e.g. when the user selects multiple rows using ctrl+mouseclick)? Any help would be appreciated :-D

    N 1 Reply Last reply
    0
    • H hakonvik

      I'm struggling to get this to work.. Is it possible to set the checked state on all the selected rows in an datagridview at the same time (e.g. when the user selects multiple rows using ctrl+mouseclick)? Any help would be appreciated :-D

      N Offline
      N Offline
      Nathan Holt at EMOM
      wrote on last edited by
      #2

      hakonvik wrote:

      I'm struggling to get this to work.. Is it possible to set the checked state on all the selected rows in an datagridview at the same time (e.g. when the user selects multiple rows using ctrl+mouseclick)?

      From reading the manual, I've come up with a minimal idea. To set checked on all rows selected, you would iterate over all the rows of your data source, and for each row check IsSelected, and if it is, set the appropriate checked value in the data source. Then you'd have to get the data grid to update its display for the new values. Nathan

      H 1 Reply Last reply
      0
      • N Nathan Holt at EMOM

        hakonvik wrote:

        I'm struggling to get this to work.. Is it possible to set the checked state on all the selected rows in an datagridview at the same time (e.g. when the user selects multiple rows using ctrl+mouseclick)?

        From reading the manual, I've come up with a minimal idea. To set checked on all rows selected, you would iterate over all the rows of your data source, and for each row check IsSelected, and if it is, set the appropriate checked value in the data source. Then you'd have to get the data grid to update its display for the new values. Nathan

        H Offline
        H Offline
        hakonvik
        wrote on last edited by
        #3

        Well, yes that is right but not quite my problem. My datagrid has an checkbox on each row in the first cell (built in code). The problem occurs when I have selected multiple rows and click one of the checkbox cells (in which case I want all the selected to get checked :-)) I can check selected rows by putting a button or link outside the grid, but that is not "normal" windows behaviour.. Any ideas:confused:

        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