0

i have an argument outofrangeexception for my datagridview.

i try to fill it. It stops when i = 1;

I dont know where is my mistake but its not the array donnee[,]

here's my code

 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

Thanks

1
  • 1
    You surely forgot to call dataGridView1.Rows.Add() Commented Aug 21, 2011 at 20:21

1 Answer 1

3

If you are filling it, you need to add rows as you go. I expect that you are currently filling the default "new data" row (as zero), but you should really be allocating your own each time, simply via .Rows.Add(). You could do this per-row, or via dataGridView1.Rows.Add(donnee.Length/4); before the loop.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.