jeudi 16 septembre 2021

CheckBox in DataGridView Won't Evaluate if Cell Has Focus

The first column in a DataGridView (dgv1) has checkboxes. Interestingly, when you click on the last checkbox desired, as soon a you loop through the rows for that column to evaluate checked items, the last cell checked (with a cursor on it) does not evaluate to true. The syntax for looping through the checkboxes in column 0 is below:

    Dim NumCBChecked As Integer = 0
    For i = 0 To dgv1.Rows.Count - 1
        If CBool(dgv1(0, i).Value) = True Then
            NumCBChecked += 1
        End If
    Next

Is there a way to set the focus to false if the cell containing the last checkbox checked is in edit mode?

BTW, refreshing the edit status (below) did not help before looping:

    dgv1.RefreshEdit()



Aucun commentaire:

Enregistrer un commentaire