在一个DataGridView中,我想限制某一单元格不可编辑,就像限制一行那样(AllowEditing=False),请问各位高人,怎么搞啊?
在线等待,谢谢!

解决方案 »

  1.   

    设置单元格的DataColumn.ReadOnly为 True 
    http://hi.baidu.com/jxhuhui/blog/item/9bb0d1fd5a715444d6887d96.html
      

  2.   

    意思是不是让一行中除了主键别的都能编辑呀? 那可以rows[i].cell[“主键”].readonly=true呀
      

  3.   

    一直在用dev的grid所以這問題不熟
      

  4.   

    应该用这个。
     dataGridView1.Rows[行].Cells[列].ReadOnly = true;
      

  5.   

    直接设置:
                    dgvData.Columns[4].ReadOnly = true;
      

  6.   

    谢谢各位,系统自带的控件已经解决了!
    但我用的这个是公司重写的,好像是把Cells,Columns没加进来,我调不出这两个属性!
    有没其它方法啊!
      

  7.   

    this.dataGridView1.CurrentCell = this.dataGridView1.Rows[2].Cells[0]; 
      this.dataGridView1.BeginEdit(false);
      

  8.   

    DataGridview.Rows[x].Cells[y].Selected=true; 
      

  9.   

    cells属性没有还要限定cell阿实在不行把主键隐藏了,反正一般都是个数字什么的。