Click here to Skip to main content
15,607,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to sum of two rows values inside the DataGridView, and create one new row in the DataGrid and display the result.

1 solution

You need to get the string value of the i-Row like this:
string sValueOne = yourDataGridView.Rows[i].Cells[j].Value;

Then the value of the next row:
string sValueOne = yourDataGridView.Rows[i+1].Cells[j].Value;

Now you need to convert the strings to decimal / double / whatever and sum the values.

To add new row you can do something like this:
DataGridViewRow row = (DataGridViewRow)yourDataGridView.Rows[i].Clone();
Share this answer
Mekalamani 18-Sep-15 8:41am    
Thanks for your reply.
add means plus the values.
I mean I want plus the first row and second row value and display in third row, Like that

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