【发布时间】:2016-11-26 06:38:57
【问题描述】:
foreach (DataGridViewRow dgvr in dataGridViewProductList.Rows)
{
string dgvrID = dgvr.Cells["ID"].Value.ToString();
DataRow[] s = DT.Select("BillID = " + dgvrID);
if (s.Length > 0)
{
dataGridViewProductList.Columns["chk"].ReadOnly = false;
dataGridViewProductList.Rows[dgvr.Index].Cells["chk"].ReadOnly = false;
dataGridViewProductList.Rows[dgvr.Index].Cells["chk"].Value = 1;
}
}
运行代码DataGridViewCheckBoxCell 后没有更改为选中状态,我该如何更改其选中状态
我试过了
DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)dataGridViewProductList.Rows[dgvr.Index].Cells["chk"];
cell.ReadOnly = false;
cell.TrueValue = true;
cell.Value = cell.TrueValue;
但不起作用。
【问题讨论】:
-
cell.Value = CheckState.Checked; -
cell.Value = CheckState.Checked;它对我不起作用@bansi -
值类型为布尔型:
.Value = true -
@Slai 不起作用
标签: c# .net winforms datagridview datagridviewcheckboxcell