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. set multiple checkboxes to true in datagridview

set multiple checkboxes to true in datagridview

Scheduled Pinned Locked Moved Visual Basic
help
2 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.
  • E Offline
    E Offline
    eyes2007
    wrote on last edited by
    #1

    hi all i have a datagridview with three columns. the first column contains checkboxes, the two and three contains text. the selection mode is fullrowselect. my problem is that, when multiple columns are selected while keeping the shift key pressed and then space is pressed with shift key all the checkboxes are supposed to be selected. i tried the code If flagShift = True And e.KeyCode = Keys.Space Then If DataGridView2.SelectedRows.Count > 1 Then For i As Integer = 0 To DataGridView2.Rows.Count - 1 If DataGridView2.Rows(i).Selected = True Then If DataGridView2.Rows(i).Cells(0).Value = True Then DataGridView2.Rows(i).Cells(0).Value = False Else DataGridView2.Rows(i).Cells(0).Value = True End If End If Next End If End If but that will check all the checkboxes except the last one. the last one remains unchecked. thanks in advance. help everyone

    M 1 Reply Last reply
    0
    • E eyes2007

      hi all i have a datagridview with three columns. the first column contains checkboxes, the two and three contains text. the selection mode is fullrowselect. my problem is that, when multiple columns are selected while keeping the shift key pressed and then space is pressed with shift key all the checkboxes are supposed to be selected. i tried the code If flagShift = True And e.KeyCode = Keys.Space Then If DataGridView2.SelectedRows.Count > 1 Then For i As Integer = 0 To DataGridView2.Rows.Count - 1 If DataGridView2.Rows(i).Selected = True Then If DataGridView2.Rows(i).Cells(0).Value = True Then DataGridView2.Rows(i).Cells(0).Value = False Else DataGridView2.Rows(i).Cells(0).Value = True End If End If Next End If End If but that will check all the checkboxes except the last one. the last one remains unchecked. thanks in advance. help everyone

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Yah, I hate this problem and I hope you get a better solution than mine. I created an additional checkbox below the gridview called checkselected. It has 2 operations: if there are no rows selected then it forces EVERY row to have its checked value. If there is 1 or more selected rows it forces the seleced rows to have the checkbox value.

      Quote from Great Outdoors: its a confident traveller who farts in India

      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