我真的需要在这段代码中,我可能会遗漏一些东西,或者我的解决方案不会接近。
我有一个数据网格绑定到DATATABLE并且我试图插入一个复选框,我想要完成的是将所有复选框设置为“已检查”状态。顺便说一下我使用mySQL所以我认为我没有选择使用BOOLEAN类型(当涉及到datagrid时,true =检查状态)。这是我的代码。任何帮助表示赞赏,TIA。
With dgvPrivilege
dim dt as new Datatable
.Datasource = dt '(already had the tables rows ("SELECT pk_id,
access_description as 'Privilege Description' FROM tbl_access_list"))
Dim checkBoxColumn As New DataGridViewCheckBoxColumn()
checkBoxColumn.HeaderText = ""
checkBoxColumn.Width = 50
checkBoxColumn.Name = "checkBoxColumn"
.Columns.Insert(0, checkBoxColumn)
.Columns(2).ReadOnly = True
For Each row As DataGridViewRow In Me.dgvPrivilege.Rows
Dim cell As DataGridViewCheckBoxCell = row.Cells(0)
cell.Value = True
Next
End with