Datagridview复选框列的值 [英] Datagridview checkbox column's value

查看:89
本文介绍了Datagridview复选框列的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个带复选框列的datagridview.我想在用户通过单击更改复选框时立即捕获其值.我尝试了几个事件(CellValueChanged,CellClicked,CurrentCellDirtyStateChanged等),但没有任何效果.
我的代码是

Hi,
I have a datagridview with a checkbox column. I want to capture the value of checkbox immediately when user changes it by clicking. I tried several events (CellValueChanged, CellClicked,CurrentCellDirtyStateChanged etc.) but nothing worked.
My code is

If dgvIDsTBC.CurrentRow.Cells(2).Value = True Then
      MsgBox("True")
End If


请告知为此使用什么事件.
谢谢
Furqan


Please advise what event to use for this.
Thanks
Furqan

推荐答案

使用CellContentClick


Use CellContentClick


Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    MsgBox(DirectCast(sender, Forms.DataGridView).Rows(e.RowIndex).Cells(e.ColumnIndex).EditedFormattedValue)
  End Sub


这篇关于Datagridview复选框列的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆