赢窗体的文本框口罩 [英] Win Forms text box masks

查看:158
本文介绍了赢窗体的文本框口罩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能把赢形式的文本框面膜,使其只允许数字?
和它是如何工作的另一个面具的数据,手机拉链等。

How can I put mask on win form text box so that it allows only numbers? And how it works for another masks data, phone zip etc.

我使用Visual Studio 2008的C#

I am using Visual Studio 2008 C#

感谢。

推荐答案

你想阻止这是不允许的输入或验证输入之前,它是可能的继续吗?

Do you want to prevent input that isn't allowed or validate the input before it is possible to proceed?

前者,当他们按下按键,但没有任何反应可能混淆用户。它通常是更好地展示自己的按键,但显示一个警告,当前的输入是无效的。这可能也是相当复杂设置掩蔽的电子邮件地址,例如正则表达式。

The former could confuse users when they press keys but nothing happens. It is usually better to show their keypresses but display a warning that the input is currently invalid. It's probably also quite complicated to set up for masking an email-address regular expression for example.

看的 ErrorProvider 以允许用户输入他们想要的东西,但显示警告信息,因为它们的类型。

Look at ErrorProvider to allow the user to type what they want but show warnings as they type.

有关您的一个文本框,只允许数字的第一个建议,你可能还需要考虑的的NumericUpDown

For your first suggestion of a text box that only allows numbers, you might also want to consider a NumericUpDown.

这篇关于赢窗体的文本框口罩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆