HMI.UI/Controls/NumberInput.cs
@@ -37,7 +37,8 @@ { // 允许输入数字、负号和小数点 Regex regex = new Regex(@"^-?\d*\.?\d*$"); string newText = this.Text.Insert(this.CaretIndex, e.Text); string segment = e.Text == "." ? ".0" : e.Text; string newText = this.Text.Insert(this.CaretIndex, segment); // 检查是否已经有负号,如果有则不允许再输入负号 if (e.Text == "-" && this.Text.Contains("-")) @@ -52,7 +53,10 @@ e.Handled = true; return; } //else if (e.Text == ".") { // e.Text = ".0"; //} //regex = new Regex(@"^-?\d*\.?\d*$|^-?\.\d*$|^-?\d+\.$"); // 验证完整的新文本是否符合数字格式 if (!regex.IsMatch(newText)) {