我在这里有一段代码,但是AttendancePercentage中的输出不断地将结果转换为整数。
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。
发布于 2015-09-05 15:41:24
尝尝这个,
dataGridView1.Columns['Column Number'].DefaultCellStyle.Format = "0.00##";在此处添加正确的列号:**Columns['Column Number']**
https://stackoverflow.com/questions/32410653
复制相似问题