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. error-cannot check the checkbox in datagrid after 2nd search

error-cannot check the checkbox in datagrid after 2nd search

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
1 Posts 1 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
    Eunice VB junior
    wrote on last edited by
    #1

    Hi, I have a datatable retrieve data in a datagrid with a checkbox column bounded to it. On the 1st data retrieval on datagrid, I'm able to check the checkbox. But if i click search to have 2nd data retrieval on datagrind, I'm unable to check the checkbox. Below is my code, i hope someone can guide me to solve this. Private selectedRows As ArrayList Private Sub dgResult_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Dim hit As DataGrid.HitTestInfo = dgResult.HitTest(e.X, e.Y) If hit.Column = 0 AndAlso hit.Type = DataGrid.HitTestType.Cell Then dgResult(hit.Row, hit.Column) = Not CBool(dgResult(hit.Row, hit.Column)) If CBool(dgResult(hit.Row, hit.Column)) Then selectedRows.Add(hit.Row) dgResult.[Select](hit.Row) Else selectedRows.Remove(hit.Row) End If End If End Sub I did run step by step to check the error. When the 2nd retrieval, it run through the codes twice. 1st, it run Private Sub dgResult_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) If hit.Column = 0 AndAlso hit.Type = DataGrid.HitTestType.Cell Then dgResult(hit.Row, hit.Column) = Not CBool(dgResult(hit.Row, hit.Column)) If CBool(dgResult(hit.Row, hit.Column)) Then selectedRows.Add(hit.Row) dgResult.[Select](hit.Row) end if end sub then continue to run it again but this time to remove the check. Private Sub dgResult_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) If hit.Column = 0 AndAlso hit.Type = DataGrid.HitTestType.Cell Then dgResult(hit.Row, hit.Column) = Not CBool(dgResult(hit.Row, hit.Column)) If CBool(dgResult(hit.Row, hit.Column)) Then selectedRows.Remove(hit.Row) end if end sub So, it seems i cannot check. But in actual, it added the check and removed the check at the same time. Can anyone help me? Thanks. eunice

    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