在dataGridView中添加复选款实现全选的功能

    技术2022-05-20  36

    #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


    最新回复(0)