tags:

views:

66

answers:

1

Hi, I have this function to see if all of a certain columns DataGridViewCheckBoxCell values are True. It however fails because it seems to think the current value is false. I'm running this code in the _CellContentClick event, is there somewhere else I could run this, after it's assigned the value to the cell?

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

Thanks a lot Cody

+1  A: 

CurrentCellDirtyStateChanged or CellValueChanged

However, I sometimes find it easy to leave the CheckBoxColumn ReadOnly and explicitly toggle the CheckedState:

cell.Value = Not cell.value

....and then checkbox values should be as expected in your further processing

Joey