【发布时间】:2013-05-23 22:15:33
【问题描述】:
我想计算单击复选框时在 datagridview 中选中的复选框的数量。
这是我的代码:
Dim count1 As Integer = 0
For Each row As DataGridViewRow In dgvAtt.Rows
If row.Cells(1).Value = True Then
count1 += 1
End If
Next
txtCnton.Text = count1
我已在 CellContentClick、CellValueChanged 和 CellStateChanged 中调用了上述过程,但计数不正确。
【问题讨论】:
-
您确定 cell(1) 是您的复选框列吗? DataGridView 列从索引 0 开始。
-
你说“它不正确计数”是什么意思?
标签: vb.net datagridview checkbox