修复温差图例表验证逻辑,在解析浮点数前先去掉单位
This commit is contained in:
@@ -219,8 +219,11 @@ namespace JoyD.Windows.CS
|
|||||||
{
|
{
|
||||||
string value = e.FormattedValue.ToString().Trim();
|
string value = e.FormattedValue.ToString().Trim();
|
||||||
|
|
||||||
|
// 去掉单位,只保留数字部分
|
||||||
|
string numericValue = System.Text.RegularExpressions.Regex.Replace(value, @"[^0-9.-]", "");
|
||||||
|
|
||||||
// 尝试解析输入为浮点数
|
// 尝试解析输入为浮点数
|
||||||
if (!float.TryParse(value, out float tempValue))
|
if (!float.TryParse(numericValue, out float tempValue))
|
||||||
{
|
{
|
||||||
dataGridViewTempDiff.Rows[e.RowIndex].ErrorText = "请输入有效的温度值";
|
dataGridViewTempDiff.Rows[e.RowIndex].ErrorText = "请输入有效的温度值";
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user