0
我在這裏有一個代碼,但AttendancePercentage中的輸出不斷將結果轉換爲整數。c#datagridview需要輸出單元格中的十進制值
A1 = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[3].Value);
A2 = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[4].Value);
decimal grade = (((A1 + A2)/(decimal)2) * 50) + 50;
double AttendancePercentage = (double)grade * (double).05;
dataGridView1.Rows[e.RowIndex].Cells[19].Value = grade;
dataGridView1.Rows[e.RowIndex].Cells[20].Value = AttendancePercentage;
假設A1 = 1,A2 = 0,所以我需要的3.75的輸出,但電池具有4
錯誤說。 「它不是定義DefaultCellStyle」 –
嘗試將其應用於整列 – iJay
如果您嘗試設置單元格格式,則這是在行模板中完成的,而不是在行中完成。 –