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. check all checkbox in datagrid window form

check all checkbox in datagrid window form

Scheduled Pinned Locked Moved Visual Basic
csharpjavascripthelptutorial
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.
  • E Offline
    E Offline
    Eunice VB junior
    wrote on last edited by
    #1

    Hi, I have a datagrid and a checkbox template column is bounded to it on the 1st column. I want to check/uncheck all the checkboxes at once when user click the check/uncheck checkbox in the header template. I got the all the sample codes in Javascript and asp. But not for vb.net window application. Can anyone guide me the codes on window application? It would be grateful if you already have the reference and send it to me. Thanks a lot for ur help.

    L 1 Reply Last reply
    0
    • E Eunice VB junior

      Hi, I have a datagrid and a checkbox template column is bounded to it on the 1st column. I want to check/uncheck all the checkboxes at once when user click the check/uncheck checkbox in the header template. I got the all the sample codes in Javascript and asp. But not for vb.net window application. Can anyone guide me the codes on window application? It would be grateful if you already have the reference and send it to me. Thanks a lot for ur help.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I found this article here on Code Project. http://www.codeproject.com/KB/grid/DataGridView_winforms.aspx[^] I converted the below method for you, from C# to VB.NET. Just wire up this event handler and set the column index to match your data grid layout. The below code assumes that the CheckBox column is the first column, so if your is not, you'll need to make a few changes: Just change the two following lines of code and replace the "0" with the correct column index. If e.ColumnIndex = **0** Then dataGridView1.Rows(i).Cells(**0**).Value = dgvColumnHeader.CheckAll

      Private Sub dataGridView1_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As DataGridViewCellMouseEventArgs)
      If e.ColumnIndex = 0 Then
      For i As Integer = 0 To dataGridView1.Rows.Count - 1
      dataGridView1.Rows(i).Cells(0).Value = dgvColumnHeader.CheckAll
      Next
      End If
      End Sub

      Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

      Just a grain of sand on the worlds beaches.

      E L 2 Replies Last reply
      0
      • L Lost User

        I found this article here on Code Project. http://www.codeproject.com/KB/grid/DataGridView_winforms.aspx[^] I converted the below method for you, from C# to VB.NET. Just wire up this event handler and set the column index to match your data grid layout. The below code assumes that the CheckBox column is the first column, so if your is not, you'll need to make a few changes: Just change the two following lines of code and replace the "0" with the correct column index. If e.ColumnIndex = **0** Then dataGridView1.Rows(i).Cells(**0**).Value = dgvColumnHeader.CheckAll

        Private Sub dataGridView1_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As DataGridViewCellMouseEventArgs)
        If e.ColumnIndex = 0 Then
        For i As Integer = 0 To dataGridView1.Rows.Count - 1
        dataGridView1.Rows(i).Cells(0).Value = dgvColumnHeader.CheckAll
        Next
        End If
        End Sub

        Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

        Just a grain of sand on the worlds beaches.

        E Offline
        E Offline
        Eunice VB junior
        wrote on last edited by
        #3

        Hi Karl, Thanks for the sharing. But in window form it doesn't have DataGridViewCellMouseEventArgs. What shall I change it to? Appreciate your help again. Thanks. cheers,eunice

        1 Reply Last reply
        0
        • L Lost User

          I found this article here on Code Project. http://www.codeproject.com/KB/grid/DataGridView_winforms.aspx[^] I converted the below method for you, from C# to VB.NET. Just wire up this event handler and set the column index to match your data grid layout. The below code assumes that the CheckBox column is the first column, so if your is not, you'll need to make a few changes: Just change the two following lines of code and replace the "0" with the correct column index. If e.ColumnIndex = **0** Then dataGridView1.Rows(i).Cells(**0**).Value = dgvColumnHeader.CheckAll

          Private Sub dataGridView1_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As DataGridViewCellMouseEventArgs)
          If e.ColumnIndex = 0 Then
          For i As Integer = 0 To dataGridView1.Rows.Count - 1
          dataGridView1.Rows(i).Cells(0).Value = dgvColumnHeader.CheckAll
          Next
          End If
          End Sub

          Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

          Just a grain of sand on the worlds beaches.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          My bad. It's been a very long day. It's the same event, ColumnHeaderMouseClick just different signature.

          Private Sub myDataGrid_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As _
          System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles myDataGrid.ColumnHeaderMouseClick

          Cheers, Karl » CodeProject 2008 MVP My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles

          Just a grain of sand on the worlds beaches.

          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