限制文本框输入 [英] Restricting TextBox Input

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

问题描述

我如何限制用户在不使用数字文本框的情况下在文本框中菜单输入字符????
发送代码给我.

解决方案

写道:​​

发送代码给我.


当然可以在我们的帮助下编写自己的代码.

如果要限制用户在文本框中输入某些字符,可以使用 解决方案

send me code.


How about writing your own code, of course with our help.

If you want to restrict users to enter certain characters in textbox you could use the handler of
KeyPress[^] event.

Here is an example:

// The KeyPress event handler
private void txtInput_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
   // Allow only numeric input
   if (!Char.IsControl(e.KeyChar) && !Char.IsDigit(e.KeyChar))
       e.Handled = true;
}



And you''ve got a manual numeric textbox.
I hope this helps. :)


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

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