Click here to Skip to main content
15,939,065 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
add rows to datagridview. the values are from using array which is dynamically from users.,
Sharath2790 26-Oct-12 1:37am    
can u explain in detail....
Sandeep Mewara 27-Oct-12 14:22pm    
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.

to add row dynamically, use this line

and assign value to each cell of newly added row like below
datagridview1.Rows[datagridview1.Rows.count-1].cells[0].value = a[i];

Happy Coding!
Share this answer
Umapathi K 27-Oct-12 7:53am    
i am getting following error

index was out of range,must be non-negative and less than the
size of the collection. parameter name:index
Aarti Meswania 27-Oct-12 8:28am    
please provide code you have done
it can be due to your array or datagrid if datagrid have no cells/columns or row which you are accessing same thing for array
dgv.rows(0).cells(0).value -> but dgv doesn't have any row so, how it will fetch rows(0) ?
MyArray[0] -> but myArray is empty then it will give you error when accessing any element through index

so, check your code
or provide some part of your code here :)
DataGridViewRow row = new DataGridViewRow();
row.SetValues(new object[] { lesson.Name, Course.Course_Name, lesson.Level, lesson.Time, Teacher.C_Name, lesson.Price, Classroom.Classroom_Name });

Share this answer
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900