全选DataGridView中的DataGridViewCheckBoxColumn选项

 代码实现:

chk全选_CheckedChanged事实

点击全选 点击取消全选

for (int i = 0; i < this.dgv.Rows.Count; i++)
            {
                 DataGridViewCheckBoxCell checkBox = (DataGridViewCheckBoxCell)this.dgv常用选项.Rows[i].Cells[0];
             
                if (this.chk全选.Checked==false)
                {
                    checkBox.Value = 0; //设置为0的时候取消全选
                }
                else if (this.chk全选.Checked==true)
                {
                    checkBox.Value = 1; //设置为1的时候全选
                }
            }

你可能感兴趣的:(chckbox)