datagridview 有checkbox a b c 按钮aa bb cc
怎样电机aa 选择全部的a 点击bb选择全部的b c同上
      for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    dataGridView1.Rows[i].Cells[0].Value = true;
                }
这种写法无效
望高手指点指点

解决方案 »

  1.   

    dataGridView1[ColIndex,Rowindex].Value=true;
      

  2.   

     foreach (DataGridViewRow row in this.Dgv_MenuSon.Rows)
                  {
                      row.Cells[0].Value = true;
                  }
      

  3.   

    this.Dgv_MenuSon.Rows
    这是什么啊
      

  4.   


    DGV没有提供这样的遍历接口
      

  5.   

    if (dataGridView1.Rows.Count > 1)
        dataGridView1.Rows[1].Cells[0].Value = true;
      

  6.   

    private void button1_Click(object sender, EventArgs e)
            {
                foreach (DataGridViewRow dr in this.dataGridView1.Rows)
                {
                    dr.Cells[0].Value = true;
                }
            }
    我刚试验过,好用的
      

  7.   

    不就是点击一个按钮时候,选中下面的所有选择框么,这种方式是正确的 我刚做的实验了,我创建的是一个Checkbox列
      

  8.   

    private void All_Start_Click(object sender, EventArgs e)
            {
                //St.Chexk_All_Start(dataGridView2);
                foreach (DataGridViewRow dr in this.dataGridView2.Rows)
                {
                    dr.Cells[4].Value = true;
                }            
            }  
      

  9.   

    看看你窗体代码生成器里面代码是这样的么 
    this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
                this.Column1});
      

  10.   

                this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
                this.set_id,
                this.Column1,
                this.Column2,
                this.Column3,
                this.set_start_id,
                this.Column4,
                this.set_end_id,
                this.Column5,
                this.set_sys1_id,
                this.Column6,
                this.set_sys2_id,
                this.Column7,
                this.set_mode1_id,
                this.Column8,
                this.set_mode2_id,
                this.Column9,
                this.set_shi_du,
                this.set_wen_du,
                this.set_ok});
      

  11.   

    this.Column1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();看看你添加的列是这种列么,这个应该不需要配置什么怎么回事呢,你查查点键钮后是不是触发了别的什么代码啊
      

  12.   

    我 datagridview里面有很多列checkbox的按钮的
      

  13.   

    我也没办法了,你仔细慢慢的从头跟下代码,怕麻烦的话就留下两行,要不然调试起来很辛苦,如果两行能通过就说明你中间某个环节出现了问题,再检查下你的Checkbook列有没有什么设置