private void DgvCheckboxSelect(bool _Value) //全部选中 { foreach (DataGridViewRow dgvRow in dgvBookRevert.Rows) { foreach (DataGridViewCell dgvCell in dgvRow.Cells) { if (dgvCell.OwningColumn.Name == "选择") { dgvCell.Value = _Value; } } } } //判断当前行是否被选中 //执行反选 if ((bool)dgvBookRevert.Rows[i].Cells[0].EditedFormattedValue == true) //设置每一行的选择框为未选中 { dgvBookRevert.Rows[i].Cells[0].Value = false; this.btnAllChecked.Text = "全部选中"; } else { //设置每一行的选择框为选中 dgvBookRevert.Rows[i].Cells[0].Value = true; this.btnAllChecked.Text = "取消选中"; }