如何在表单加载时自动在DataGridview中选中复选框?
试图将此代码放入表单加载中,但现在就可以了
Dim chkbox As New DataGridViewCheckBoxColumn
DataGridView4.Columns.Insert(0, chkbox)
For Each row As DataGridViewRow In DataGridView4.Rows
Dim cell As DataGridViewCheckBoxCell = row.Cells(0)
cell.Value = True
Next
假设您已经有一个空列0,那么您可以这样做:
For Each row As DataGridViewRow In DataGridView4.Rows
row.Cells(0) = New DataGridViewCheckBoxCell With {.Value = True}
Next