datagridview复选框计数器 [英] datagridview checkbox counter

查看:96
本文介绍了datagridview复选框计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我正在尝试计算datagridview中选中的复选框的数量,但计数器的返回值为0.
谁能给我一个线索,为什么会这样?

Hi all!

I''m trying to count the number of the checked checkboxes in the datagridview, but the counter return value is 0.
Can anyone give me a clue why that is so?

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

        Dim pcount As Integer = 0
        For Each row As DataGridViewRow In DataGridView1.Rows
            If row.Cells(0).Value = True Then
                pcount += 1
            End If
        Next
        Label2.Text = pcount
    End Sub




谢谢!




Thanks!

推荐答案

在执行事件之前,必须以表格加载的方式再次将网格重新绑定到数据集!使用DEBUGGER,看看是否是这种情况.
You must be re-binding the grid to dataset again in form load, before the event is executed! Use DEBUGGER and see if that''s the case.


这篇关于datagridview复选框计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆