如何在DatagridView Checkbox vb.net中保持复选框处于选中状态

时间:2018-11-24 06:59:40

标签: vb.net

如何在表单加载时使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

1 个答案:

答案 0 :(得分:0)

假设您已经有一个空的第0列,则可以执行以下操作:

For Each row As DataGridViewRow In DataGridView4.Rows
    row.Cells(0) = New DataGridViewCheckBoxCell With {.Value = True}
Next