怎样在dataGridView的指定单元格中赋值??例如:我想在dataGridView的第3行第5列赋值“你好”,应该怎样写??
我是了很多方法,总是出现错误,错误信息是“索引超出范围。必须为非负值并小于集合大小。参数名: index”。
就是在指定的单元格里面赋个值而已,怎么着么难啊!!!
在线等。。

解决方案 »

  1.   

    dataGridView.Rows[3].Cells[4].value="你好"
      

  2.   

    this.dataGridView[2,4]="你好"; 
    dataGridView 的索引都是从零开始的
     
      

  3.   

    dataGridView[4,2]="你好"; 
    注:[4,2]号中的第一个数字是列的索引,第二个数字是行的索引。
      

  4.   

    首先要确定你的datagridview至少有3行5列。
      

  5.   

    for(int rowIndex=0;rowIndex<dataGridView.Rows.length;rowIndex++)
    {
       for(int columnIndex=0;columnIndex<dataGridView.Rows   
                           [rowIndex].Cells.length;columnIndex++)
       {
            dataGridView.Rows[i].Cells[columnIndex].value="Row" + rowIndex + 
                                                          " column" + columnIndex;
       }
    }
    看看这样行不行.
      

  6.   

    不好用吧  dataGridView[5,3]返回的是DataGridViewCell类型
    加个.Vale
    this.dataGridView1[0, 0].Value = "哈哈哈哈";
    索引从0开始  【】中第一个是列号 第二个是行号
    3行5列 就是
    this.dataGridView1[4,2].Value = "哈哈哈哈";
    就行了
      

  7.   

     sadfasdf asd fas dfsa fas df asd fasd fsadf asd
      

  8.   

    f dasf asdf asdfsa df asdf asd fasd f