Click here to Skip to main content
14,692,401 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
if I have DataGrid with 4 columns as you can see
--------------------------------
Col1    Col2    Col3     Col4
--------------------------------
5000                        3250
--------------------------------
3250                        2300
--------------------------------
2300                        result
--------------------------------

Col1 has a value and Col2 and Col3 make a formula on that value Col4 print the result.
I want to set that result to the next cell on Col1 and again Col2,3 apply the formula and so on.
I have tried the next snippet code but It's applied on all cells in the column.

What I have tried:

for (int i = 1; i < dgv.Rows.Count; i++)
        {
           dgv.Rows[i].Cells[1].Value = result;
        }
Posted
Updated 6-Oct-19 6:09am

1 solution

You're applying the SAME "result" to each row. You need to calculate a NEW result every time you access a new / next row.
   
Comments
Maciej Los 7-Oct-19 5:16am
   
Short And To The Point!

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