简体   繁体   English

如何计算在 VB.NET 中的 datagridview 中检查的复选框

[英]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大家好,我有一些关于 datagridview 复选框的问题.. 问题是我想计算已在 datagridview 中选中的复选框,并向用户显示已选中的复选框数量,但显示的复选框少于我选中的一个

    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只需在之前放置一个 EndEdit

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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