[英]Datagridview checkbox column's value
我有一个带复选框列的DataGridView。 当用户通过单击更改复选框时,我想立即捕获复选框的值。 我尝试了几个事件( CellValueChanged
, CellClicked
, CurrentCellDirtyStateChanged
等),但没有任何效果。
这是我的代码:
If dgvIDsTBC.CurrentRow.Cells(2).Value = True Then
MsgBox("True")
End If
请帮忙
希望这可以帮助
void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 3)
MessageBox.Show(dataGridView1[e.ColumnIndex, e.RowIndex].FormattedValue.ToString());
}
这个我认为你会做的,现在捕获是除非你移出网格认为你仍在编辑的单元格,所以添加这个部分
void dataGridView1_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex == 3)
dataGridView1.EndEdit();
}
这应该没问题,3是你想要它的复选框列
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.