28
2012
03

datagridview操作之数据全选和反选

///
/// 数据全选
///

///
///
private void btnCheckAll_Click(object sender, EventArgs e)
{
for (int i = 0; i < dgvSafeNum.RowCount; i++)
{
dgvSafeNum.Rows[i].Cells[0].Value = true;
}
}

///
/// 数据反选
///

///
///
private void btnNot_Click(object sender, EventArgs e)
{
for (int i = 0; i < dgvSafeNum.RowCount; i++)
{
bool check = Convert.ToBoolean(dgvSafeNum.Rows[i].Cells[0].FormattedValue);
if (check == false)
{
dgvSafeNum.Rows[i].Cells[0].Value = true;
}
else
{
dgvSafeNum.Rows[i].Cells[0].Value = false;
}
}
}
« 上一篇下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。