我有一个DataGridView
包含DataGridViewColumn
一个按钮和一个按钮。当我单击按钮时,我想检查是否选中了 datagridview 中的所有复选框。
我使用以下代码,但它不起作用:
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