10
    20
    30
    ______
    60
    this 60 i want in textbox.for that i am using below code. but it is not calculating total , it is concatenating the amount. so which changes should i made in this below code


foreach(datagridviewrow item in datagridview1.rows)
{
    int n = item.Index;
    textbox1.text = textbox1.text + datagridview1.rows[n].cells[2].value;
}

On line 12, you are using the concatenate operator (+) for strings.
Try this instead:

int sum = 0;
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                sum += Convert.ToInt32(row.Cells[2].Value);
            }
            textbox1.text = sum.ToString();

Also have a look at this snippet

Be a part of the DaniWeb community

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