Home > Enterprise >  How to calculate checkbox that been check in datagridview in VB.NET
How to calculate checkbox that been check in datagridview in VB.NET

Time:11-16

Hello guys i got some question about datagridview checkbox.. the thing is that i want to calculate the checkbox that have been checked in datagridview and show it to user how many that have been check but it show less than one that i checked

    Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    Dim kk As Integer = 0
    For Each row As DataGridViewRow In DataGridView1.Rows
        Dim checkselect As Integer = Convert.ToInt16(row.Cells("chkCheck").Value)
        If checkselect = 1 Then
            kk  = 1
        End If
    Next
    lblSelect.Text = kk
End Sub

This is the coding that i want to calculate and show to user..can anyone find my mistake

enter image description here

This how it goes

CodePudding user response:

Just put a EndEdit before

 DataGridView1.EndEdit()
 Dim kk As Integer = 0
 For Each row As DataGridViewRow In DataGridView1.Rows
  • Related