I have a DataGridView which contains a DataGridViewColumn and also a button. When I click the button I want to check if all checkboxes in the datagridview are checked or not.
I use the following code but it is not working:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For i As Integer = 0 To DataGridView1.Rows.Count - 1
Dim CheckBox As DataGridViewCheckBoxCell = DirectCast(DataGridView1.Rows(i).Cells(0), DataGridViewCheckBoxCell)
If Not CheckBox.Value = Not CheckBox.Value Then
MsgBox("True")
End If
Next
End Sub
If Not CheckBox.Value = Not CheckBox.Value ThenThis will always evaluate true.