Monday, 4 August 2014

how to calculate datagrid colums in c#



private void dataGridView1_CellEndEdit(object sender,DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 || e.ColumnIndex == 1)
            {
                int cell1 =Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value);
                int cell2 =Convert.ToInt32(dataGridView1.CurrentRow.Cells[1].Value);


                if (cell1.ToString() != "" && cell2.ToString() !="")
                {
                    dataGridView1.CurrentRow.Cells[2].Value = cell1 + cell2;
                }

            }
        }

No comments:

Post a Comment