i have 2 column PRICE and PAYMENT in Datagrid
when i change value of 1 any cell in this Datagrid, other cells also change the value.
Example:
PRICE | PAYMENT
100 | 80 |
20 | 10 |
10 | 5 |

Note:
Row2.cells[0] = row1.cells[0] - row1.cells[1]
similar: row3.cells[0] = row2.cells[0] - row2.cells[1]
Column 1 have value read only. Only column 2 can edit value
Value each row change depends previous line.

when i change value row1.cells[1]= 60, it change below:
row2.cells[0]=40
row2.cells[1] = 40
row3.cells[0] = 0
row3.cells[1] = 0

It change or it should change?? What you want and what you are getting please be clear also tell us what have you done so far?

i have 2 that column, i edit any row of Colum 2,value of Row, Colum 1,2 change

private void dgvPayment_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
     addValue();
     changeValue();
     dgvPayment.Refresh();
}

private void addValue()
{
            DataTable dt = new DataTable();
            DataRow row;
                        
            dt.Columns.Add("PRICE");
            dt.Columns.Add("PAYMENT");

            row = dt.NewRow();
            row["PRICE"] = txtPrice.Text;
            row["PAYMENT"] = txtPrice.Text;
           // Row1 of Datagrid alway = TotalPrice, next rows always =0
            dt.Rows.Add(row);                          
 
}
private void changeValue()
{
            int numberVotes= Convert.ToInt32(txtNumberVotes.Text);
            int Row_i = 0;

            int totalPrice = 0;
            totalPrice = Convert.ToInt32(txtPrice.text);
            int left=0;

            for(int i=1;i< numberVotes;i++ )
            {     
                 Row_i = dgvPayment.Rows[i-1].Cells["PAYMENT"];
                 if(Row_i < totalPrice)
                 {
                   left = totalPrice - Row1;
                   // Get value left for next rows of Column PAYMENT
                   dgvPayment.Rows[i].Cells["PAYMENT"].Value = left.ToString();
                   totalPrice = left;
                 }              
            
            }                             
}
Comments
Confused :(

Do you mean on changing any of the cell's value all other cells' values change automatically??? Strange.... You want this change on which basis?

This article has been dead for over six months. Start a new discussion instead.