我有一个DataGridView
其中包含一个DataGridViewColumn
,也是一个按钮。当我点击按钮时,我想检查是否选中了datagridview中的所有复选框。检查是否选中复选框DataGridViewCheckBoxCell
我用下面的代码,但它不工作:
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
'如果不CheckBox.Value =不CheckBox.Value Then'这将始终评估真实。 –