vb.net DataGridViewCheckBox 状态

来源:互联网 发布:淘宝自动优惠怎么取消 编辑:程序博客网 时间:2024/04/30 05:42

DataGridViewCheckBox单元格点击时,出现的问题。

点击该单元格,非CheckBox部分,虽然此时CheckBox没有选中,但是在后台代码中值已经更改。

 

Dim cell AS DataGridViewCheckBoxCell = dgvList.Rows(e.RowIndex).Cells("列名")

cell.ReadOnly = true

Dim checked As boolean  = cell.EditFormattedValue

If checked Then

  cell.Value = true

Else

  cell.Value = false

End If

 

注意红色字[cell.ReadOnly = true],设置后,点击CheckBox以外部分空白部分,和点击CheckBox,效果一致。

0 0
原创粉丝点击