简体   繁体   中英

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

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

在此处输入图片说明

This how it goes

Just put a EndEdit before

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM