在winforms中选中标题复选框时,选择datagridview中的整个复选框的代码? [英] Code to select the whole checkbox in datagridview when the header checkbox is selected in winforms?

查看:69
本文介绍了在winforms中选中标题复选框时,选择datagridview中的整个复选框的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其他复选框未被选中



我尝试过:



other checkboxs is not getting selected

What I have tried:

private void checkboxHeader_CheckedChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                dataGridView1[0, i].Value = ((CheckBox)dataGridView1.Controls.Find("checkboxHeader", true)[0]).Checked;

            }
            for (int j = 0; j <= dataGridView1.RowCount - 1; j++)
            {
                dataGridView1[j, 0].Value = ((CheckBox)sender).Checked;
            }
            dataGridView1.EndEdit();
            
          
        }

推荐答案

试试这个:



Try this:

DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell(dataGridView1.Rows[j].Cells[0]);
cell.Value = cell.TrueValue;


这篇关于在winforms中选中标题复选框时,选择datagridview中的整个复选框的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆