From 42e6b8e67e2ef22185174f70e02073f7f47faa25 Mon Sep 17 00:00:00 2001 From: Sunny Date: Tue, 7 Mar 2023 22:55:31 +0800 Subject: [PATCH] =?UTF-8?q?*=20UIEdit:=20=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=BA=E7=A9=BA=E6=97=B6=E5=B0=8F=E6=95=B0?= =?UTF-8?q?=E4=BD=8D=E6=95=B0=E5=92=8C=E8=AE=BE=E7=BD=AE=E5=80=BC=E4=B8=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UIEdit.cs | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/SunnyUI/Controls/UIEdit.cs b/SunnyUI/Controls/UIEdit.cs index 330fcb19..201dd49f 100644 --- a/SunnyUI/Controls/UIEdit.cs +++ b/SunnyUI/Controls/UIEdit.cs @@ -18,6 +18,7 @@ * * 2020-01-01: V2.2.0 增加文件说明 * 2022-12-18: V3.3.0 修复了一个最小值大于0是,显示类型为字符串Text为空仍有显示的问题 + * 2023-03-07: V3.3.3 修复了删除为空时小数位数和设置值不一致的问题 ******************************************************************************/ using System; @@ -33,11 +34,6 @@ namespace Sunny.UI { private bool canEmpty; private int decLength = 2; - //private bool hasMaxValue; - //private bool hasMinValue; - private string mask = "0.00"; - //private double maxValue = int.MaxValue; - //private double minValue = int.MinValue; private UITextBox.UIEditType _uiEditType = UITextBox.UIEditType.String; public UIEdit() @@ -408,7 +404,7 @@ namespace Sunny.UI case UITextBox.UIEditType.Double: if (!CanEmpty) if (!Text.IsDouble()) - Text = mask; + Text = 0.ToString("f" + decLength); break; case UITextBox.UIEditType.Integer: @@ -444,8 +440,7 @@ namespace Sunny.UI if (_uiEditType == UITextBox.UIEditType.Double) { - mask = DecimalToMask(decLength); - Text = DoubleValue.ToString(mask); + Text = DoubleValue.ToString("f" + decLength); Invalidate(); } } @@ -488,16 +483,6 @@ namespace Sunny.UI } } - private string DecimalToMask(int iDecimal) - { - if (iDecimal == 0) - return "0"; - var str = "0."; - for (int i = 1; i <= iDecimal; i++) - str = str + "0"; - return str; - } - private int SubCharCount(string str, char subChar) { string[] IDList = str.Split(subChar); @@ -755,7 +740,7 @@ namespace Sunny.UI // Text = Text.Insert(1, @"0"); if (!double.TryParse(Text, out var doubleValue)) - Text = mask; + Text = 0.ToString("f" + decLength); else Text = doubleValue.ToString("f" + decLength); }