如何在DatagridView Checkbox vb.net中选中复选框

问题描述 投票:0回答:1

如何在表单加载时自动在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
vb.net
1个回答
0
投票

假设您已经有一个空列0,那么您可以这样做:

For Each row As DataGridViewRow In DataGridView4.Rows
    row.Cells(0) = New DataGridViewCheckBoxCell With {.Value = True}
Next
© www.soinside.com 2019 - 2024. All rights reserved.