-1
如何計算按鈕上的dataGridView列中存儲的整數值和浮點值的總和,然後將其存儲到文本框中?如何計算總和。 dataGridView列中的值?
如何計算按鈕上的dataGridView列中存儲的整數值和浮點值的總和,然後將其存儲到文本框中?如何計算總和。 dataGridView列中的值?
int sum = 0;
foreach (DataGridViewRow row in dataGridView.Rows)
{
//here 0 is the index of columns you want to get values from
// you can also use column name instead of index
sum += (int) row.Cells[0].Value;
}
//for showing the user message box
MessageBox.Show("Sum of all the values is {0}", sum.ToString());