我有一個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'這將始終評估真實。 –