#region 全选/反选
/// <summary>
/// 全选反选操作
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">e</param>
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox1.Checked == true)
{
if (this.DgvOrdersGoods.Rows.Count > 0)
{
for (int i = 0; i < this.DgvOrdersGoods.Rows.Count; i++)
{
this.DgvOrdersGoods.Rows[i].Cells[1].Value = true;
}
}
}
else
{
if (this.DgvOrdersGoods.Rows.Count > 0)
{
for (int i = 0; i < this.DgvOrdersGoods.Rows.Count; i++)
{
if ((bool)this.DgvOrdersGoods.Rows[i].Cells[1].EditedFormattedValue)
{
this.DgvOrdersGoods.Rows[i].Cells[1].Value = false;
}
else
{
this.DgvOrdersGoods.Rows[i].Cells[1].Value = true;
}
}
}
}
}
#endregion
在dataGridView中添加复选款实现全选的功能
最新推荐文章于 2021-11-03 15:37:46 发布