gx
This commit is contained in:
@@ -254,12 +254,31 @@ namespace WindowsFormsApp6
|
|||||||
{
|
{
|
||||||
if (e.RowIndex < 0 || e.ColumnIndex == 0) return; // 跳过序号列
|
if (e.RowIndex < 0 || e.ColumnIndex == 0) return; // 跳过序号列
|
||||||
|
|
||||||
|
// 获取当前行的序号,判断是否是标准偏差行
|
||||||
|
string rowName = "";
|
||||||
|
if (e.RowIndex < dataGridView1.Rows.Count)
|
||||||
|
{
|
||||||
|
var row = dataGridView1.Rows[e.RowIndex];
|
||||||
|
if (row.Cells["序号"].Value != null)
|
||||||
|
{
|
||||||
|
rowName = row.Cells["序号"].Value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 格式化数值显示为2位小数
|
// 格式化数值显示为2位小数
|
||||||
if (e.Value != null && e.Value != DBNull.Value)
|
if (e.Value != null && e.Value != DBNull.Value)
|
||||||
{
|
{
|
||||||
if (double.TryParse(e.Value.ToString(), out double numValue))
|
if (double.TryParse(e.Value.ToString(), out double numValue))
|
||||||
{
|
{
|
||||||
// 如果值为0或接近0,显示为空白
|
// 标准偏差行:即使为0也要显示
|
||||||
|
if (rowName == ROW_STD_DEVIATION)
|
||||||
|
{
|
||||||
|
e.Value = numValue.ToString("F2");
|
||||||
|
e.FormattingApplied = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其他行:如果值为0或接近0,显示为空白
|
||||||
if (Math.Abs(numValue) < 0.001)
|
if (Math.Abs(numValue) < 0.001)
|
||||||
{
|
{
|
||||||
e.Value = "";
|
e.Value = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user