Mark Mashup

Mark Mashup

  • NA
  • 10
  • 2.9k

i have student mark, then one student absent do datagridview

Aug 13 2015 1:41 AM
if (dataGridView2.CurrentCell.ColumnIndex < 5)
{
int sum = 0;
//int average = 0;
for (int j = 0; j < dataGridView2.Rows.Count - 1; j++)
{
for (int i = 0; i < dataGridView2.Columns.Count - 2; i++)
{
//char a = 'a';
if (dataGridView2.Rows[j].)
{
}
//{
// a='0';
// dataGridView2.CurrentRow.Cells[i].Value = dataGridView2.CurrentCell.RowIndex.ToString();
//}
//if else(dataGridView2.CurrentCell.RowIndex!='a')
sum += Convert.ToInt32(dataGridView2.Rows[j].Cells[i].Value);
}
} dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells["dgvctotal"].Value = sum.ToString();
int b = (int.Parse(sum.ToString())) / (int.Parse(dataGridView2.Columns.Count.ToString()) - 2);
dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells["dgvcaverage"].Value = b.ToString();
}
}

Answers (2)