文本框仅接受1到12之间的数字作为输入,不输入其他任何内容 [英] textbox to take only numbers from 1 to 12 as input and not anything else

查看:149
本文介绍了文本框仅接受1到12之间的数字作为输入,不输入其他任何内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单中有文本框,我只希望它只包含1到12之间的数字,而没有其他皮带...我正在尝试,但是我没有得到它的逻辑

i have textbox in my form and i want it take only numbers from 1 to 12 only and not any thong else...i am trying but iam not getting the logic for it

推荐答案

您说您正在尝试,但未显示任何证据.您可以在文本框的按下事件中使用Char.IsNumeric和Char.IsControl以仅允许数字.然后,您可以使用int.TryParse来查看最终得出的数字是否不在您的范围内,如果存在则将其删除.
You say you are trying, but show no evidence of it. You can use Char.IsNumeric and Char.IsControl in the key down event of a textbox to allow only numbers. You can then use int.TryParse to see if the number that you end up with is not in your range, and erase it if it is.


这篇关于文本框仅接受1到12之间的数字作为输入,不输入其他任何内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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