-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());