(WinForm中DataGridView控件通过复选框实现多条记录的删除)代码如下:
private void btnDelete_Click(object sender, EventArgs e)
{
string strNames = "您选择的是:";
for(int i=0;i<dgvList.Rows.Count;i++)
{
if (dgvList.Rows[i].Cells[0].Value != null) //判断该行的复选框是否存在
{
if (dgvList.Rows[i].Cells[0].Value.ToString() == "True") //判断该复选框是否被选中
{
strNames += dgvList.Rows[i].Cells[2].Value.ToString() + " ";
}
}
}
MessageBox.Show(strNames, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
联系客服