简体   繁体   中英

How to keep the checkbox checked in DatagridView Checkbox vb.net

How to make checkbox automatically checked in DataGridview on form load?

Tried to put this code in form load but it does now

    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

Assuming you already have an empty column 0 then you can do this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM