Click here to Skip to main content
13,800,704 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I want the answer like this:
Column A	Column B	Column C
12.02	         10.00	         22.02
32.02            10.00           42.02
52.02


What I have tried:

private void DgView_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
         if (DgView.CurrentCell.ColumnIndex == 0)
                {
                    DgView.Rows[DgView.CurrentCell.RowIndex].Cells[1].Value =                         cfun.convertdecimal(DgView.Rows[DgView.CurrentCell.RowIndex].Cells[0].Value.ToString())  + cfun.convertdecimal(txtValue.Text.ToString());
                }
}
 private void DgView_RowValidated(object sender, DataGridViewCellEventArgs e)
        {
            decimal sum = 0;

            for (decimal i = 0; i < DgView.Rows.Count+1; ++i)
            {
                sum = cfun.convertdecimal(DgView.Rows[DgView.CurrentCell.RowIndex].Cells[1].Value.ToString())
                     + cfun.convertdecimal(DgView.Rows[DgView.CurrentCell.RowIndex].Cells[2].Value.ToString());
            }
            DgView.Rows[DgASideView.CurrentCell.RowIndex].Cells[0].Value = sum.ToString();
        }
when i try this code 1st row 1st column is changing.want to display the sum in 2nd row 1st column and continuously
Posted 5-Dec-18 23:04pm
Updated 6-Dec-18 0:02am
v3
Comments
Richard MacCutchan 6-Dec-18 4:39am
   
What is the problem?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

See answers here: Math calculation in datagrid view[^]
And: https://www.codeproject.com/Answers/1268855/How-to-sum-repeated-rows-in-datgridview-and-show-i#answer3
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.181215.1 | Last Updated 6 Dec 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100