for (int i = 0; i <= datagridview.Rows.Count; i++)
{
bool ischecked = (bool)datagridview.Rows[i].Cells[0].FormattedValue;
if (ischecked)
{
MessageBox.Show("yes!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("no!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
} 为什么当我把鼠标放在datagridview的某行上的数据时候,该行的Cells[0]的checkbox不管选中与否都被判断为"未选中"?
{
bool ischecked = (bool)datagridview.Rows[i].Cells[0].FormattedValue;
if (ischecked)
{
MessageBox.Show("yes!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("no!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
} 为什么当我把鼠标放在datagridview的某行上的数据时候,该行的Cells[0]的checkbox不管选中与否都被判断为"未选中"?
for (int i = 0; i <= datagridview.Rows.Count; i++)
{
bool ischecked = (bool)datagridview.Rows[i].Cells[0].Value;
if (ischecked)
{
MessageBox.Show("yes!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("no!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
出错提示:未将对象引用设置到对象的实例。
有convert转换一下
结束编辑状态就可以了!