0

我的 datagridview 有一个参数 outofrangeexception。

我试着填满它。当 i = 1 时停止;

我不知道我的错误在哪里,但不是数组donnee[,]

这是我的代码

 for(int i = 0; i < donnee.Length/4; i++){
                    dataGridView1.Rows[i].Cells[0].Value = donnee[i,0];
                    dataGridView1.Rows[i].Cells[1].Value = donnee[i,1];
                    dataGridView1.Rows[i].Cells[2].Value = donnee[i,2];
                    dataGridView1.Rows[i].Cells[3].Value = donnee[i,3];
                }//REMPLIR DATAGRIDVIEW

谢谢

4

1 回答 1

3

如果要填充它,则需要随时添加行。我希望您当前正在填充默认的“新数据”行(为零),但是您实际上应该每次都分配自己的,只需通过.Rows.Add(). 您可以按行执行此操作,也可以dataGridView1.Rows.Add(donnee.Length/4);在循环之前执行此操作。

于 2011-08-21T20:19:42.410 回答