HI everyone,

i am currently having problems with Datagridview, for example when i select the first checkbox, second checkbox onwards.

I would like to update the textbox on my form to display '2' records selected. But there is one problem i faced is that when i deselect the checkbox, it does not update. It still display '2' record selected. What event handler should i use to get it to work?

Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvAssignGridView.CellContentClick

        Dim pcount As Integer = 0
        For Each row As DataGridViewRow In dgvAssignGridView.Rows
            If row.Cells(6).Value = True Then
               pcount += 1
            Else
                pcount += 0
            End If
        Next
       Label1.Text = pcount.ToString
    End Sub

Hi,

Put the Label part inside the For Each loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.