vb.net DataGridViewCheckBox 状态

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,效果一致。

猜你喜欢

转载自blog.csdn.net/piaoxueergogo/article/details/48318977
今日推荐