I need to add Column1 + Column2 And Display Result In Column3
But I need to do it for all rows in column3 automatically. I need a very short code.

Thankyou.

Recommended Answers

sum = Convert.ToInt32(dataGridView1.Rows(i).Cells(0).Value)
+ Convert.ToInt32(dataGridView1.Rows(i).Cells(2).Value)

This adds two integers in column 1 and 3 of row i together.
Store sum in the Value of a column you want.

Jump to Post

All 2 Replies

sum = Convert.ToInt32(dataGridView1.Rows(i).Cells(0).Value)
+ Convert.ToInt32(dataGridView1.Rows(i).Cells(2).Value)

This adds two integers in column 1 and 3 of row i together.
Store sum in the Value of a column you want.

What Is declare as "i" ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.