从datagrid视图获取复选框值 [英] getting Check box value from datagrid view
问题描述
大家好,
我在datagrid视图中添加了一个复选框列.
我希望用户仅选中一个复选框(即一次选择一个记录)
我使用了单元格点击事件
私有void myDataGridView_CellClick(对象发送者,DataGridViewCellEventArgs e)
{
DataGridViewCheckBoxCell Check =(DataGridViewCheckBoxCell)myDataGridView.Rows [e.RowIndex] .Cells [0];
如果(Check.Value!= null)
{
如果(Check.Value =="True")
{
int r = e.RowIndex;
}
}
其他
返回;
}
但是当我选择/勾选任何复选框时,为什么将值设为null?
我将True值设为True& FalseValue为CheckBox的datagrid视图列的false.
如果您知道这个plz,请告诉我
hello every body,,
i add a check box column in datagrid view.
i want user should check only one check box (i.e select one record at a time)
i used cell click event
private void myDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewCheckBoxCell Check = (DataGridViewCheckBoxCell)myDataGridView.Rows[e.RowIndex].Cells[0];
if (Check.Value != null)
{
if (Check.Value == "True")
{
int r = e.RowIndex;
}
}
else
return;
}
but as i select/tick any check box it take value as null why?
i set the true value to True & FalseValue to false of datagrid view''s column of CheckBox.
if u know this plz tell me
推荐答案
Check.Value =="True")
Check.Value == "True")
尝试类似Check.Checked = true;
.
Try something like Check.Checked = true;
.
这篇关于从datagrid视图获取复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!