如何限制一个人不要在文本框中粘贴非数字值? [英] How one can restrict one to not to paste a non-numeric value in textbox?

查看:74
本文介绍了如何限制一个人不要在文本框中粘贴非数字值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框,说"ISD代码",允许用户仅输入数字值.我在事件句柄的帮助下限制了用户,以便不允许他/她输入数字值,但他/她可以从其他位置复制数字值并将其粘贴到文本框中.

但是我面临的问题是如果用户从某个地方复制"abc"然后将其粘贴到文本框中,该怎么办.他能够这样做.如何对此进行限制."

在此先感谢

Varun Sareen
软件开发人员

I have a textbox say, "ISD Code" in which the user is allowed to enter only numeric values. I have restricted user with the help of event handle so that he/she is not allowed to enter the numeric value but he/she can copy the numeric value from somewhere else and can paste it in the textbox.

But the problem i am facing is that "What if the user is copying "abc" from somewhere and then pasting it to the textbox. he is able to do so. How to put restriction over this."

Thanks in advance

Varun Sareen
Software Developer

推荐答案

使用MaskedTextBox并将掩码设置为数字.请参见此处 [
Use a MaskedTextBox and set the mask to numeric. See Here[^]


这篇关于如何限制一个人不要在文本框中粘贴非数字值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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