datagridview中某一列设置成checkbox控件,但是在有些行里不需要这些checkbox,怎么使某一个单元格里的checkbox不可选(变灰)。
我开始想用 dataGridView1.Rows[0].Cells[5].enable = false;可是没有enable属性。
似乎要用dataGridView1.Rows[0].Cells[5].style里的某些属性,我还没有研究出来。希望遇到过这个问题的前辈帮我解决一下!

解决方案 »

  1.   

    可以设定ReadOnlydataGridView1.Rows[0].Cells[5].ReadOnly = True
      

  2.   

    Readonly = true
    可是还是存在的。能让他变灰也行呀,就像enable的效果最好,让他完全消失也行!
      

  3.   

    readonly不是已经有灰了嘛.
    要消失的话就VISIBLE=false
      

  4.   

      private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
            {
                if (e.ColumnIndex == 0&&e.RowIndex>-1)
                {
                    this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly = true;
                    this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.FromArgb(236, 233, 216);
                    this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = false;
                }
            }
      

  5.   

    readonly可不是变灰的,你可以自己看看效果的。
    老大,VISIBLE属性这里是只能取值不能设置的。试一下就知道了1