【发布时间】:2014-11-09 09:25:19
【问题描述】:
在 windows 窗体应用程序中,C# 使用 Visual Studio 2012
我的掩码是 0.00,但是当我输入 3.00 时,它只考虑 3 而不是 3.00 并且当输入 3.30 它考虑 3.3 但如果我输入 3.01 则考虑这个值。
问题是我希望它也考虑最后一个零。
在表单设计器代码中:
this.maskedTextBox1.Location = new System.Drawing.Point(402, 121);
this.maskedTextBox1.Mask = "0.00";
this.maskedTextBox1.Name = "maskedTextBox1";
this.maskedTextBox1.PromptChar = '-';
this.maskedTextBox1.Size = new System.Drawing.Size(31, 22);
this.maskedTextBox1.TabIndex = 23;
this.maskedTextBox1.ValidatingType = typeof(System.DateTime);
this.maskedTextBox1.MaskInputRejected += new
System.Windows.Forms.MaskInputRejectedEventHandler(this.maskedTextBox1_MaskInputRejected);
【问题讨论】:
-
显示
maskedTextBox1_MaskInputRejected内的代码 -
maskedTextBox1_MaskInputRejected 为空.. 因为 0 默认只允许 0 到 9 位数字作为微软的网站msdn.microsoft.com/en-us/library/…
-
您能解释一下为什么将 DateTime 用作 ValidatingType 而不是小数(或双精度...)
-
@steve 实际上我想验证双精度...becz 用户在此字段中输入他们的 gpa/标记.. 包括小数点,如 3.44 3.00 等,但仅限于 0-9 位数字..this工作正常,但不适用于我在上面的查询中提到的特殊情况。
标签: winforms mask maskedtextbox