Datagridview复选框列的 [英] Datagridview checkbox column's
本文介绍了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
Private Sub DataGridViewX3_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridViewX3.CellContentClick
If DataGridViewX3.Rows(DataGridViewX3.CurrentCell.RowIndex).Cells(8).Value = True Then
DataGridViewX3.Rows(DataGridViewX3.CurrentCell.RowIndex).Selected = True
End If
推荐答案
请检查以下帖子.他们也接受了答案.
1. 在DataGridView C#中触发复选框值更改事件. NET [ ^ ].
2. Datagridview checkbox.checked事件 [ ^ ].
3. 在Windows Forms DataGridview中捕获复选框单击事件 [ ^ ] .
快乐编码
谢谢...
Please check the below posts. They have accepted answers also.
1. Triggering a checkbox value changed event in DataGridView C#.NET[^].
2. Datagridview checkbox.checked event[^].
3. Capturing Checkbox click event in Windows Forms DataGridview[^].
Happy coding
Thanks...
Private Sub DataGridViewX3_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)Handles DataGridViewX3.CellContentClick
DataGridViewX3.CommitEdit(DataGridViewDataErrorContexts.Commit)
End Sub
Private Sub DataGridViewX3_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridViewX3.CellValueChanged
'' do something with grid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value
End If
End Sub
这篇关于Datagridview复选框列的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文