我有这个函数来查看某些列DataGridViewCheckBoxCell值是否为True。然而它失败了,因为它似乎认为当前值是错误的。我在_CellContentClick事件中运行此代码,在将值分配给单元格后,是否还有其他地方可以运行此代码?
Private Function AllTasksAreCompleted() As Boolean
Dim result As Boolean = True
For Each dgvRow As DataGridViewRow In Me.gridTasks.Rows
Dim tempCBcell As DataGridViewCheckBoxCell = GetCheckBoxCell(dgvRow, "colCompleted")
If Not tempCBcell.Value.ToString = "True" Then
result = False
Return result
End If
Next
Return result
非常感谢 科迪
答案 0 :(得分:1)
CurrentCellDirtyStateChanged或CellValueChanged
但是,我有时会发现离开CheckBoxColumn ReadOnly并显式切换CheckedState很容易:
cell.Value = Not cell.value
....然后复选框值应该在您的进一步处理中按预期进行