需要对表单中的文本字段进行控制验证 [英] need control validation to a textfield in a form

查看:79
本文介绍了需要对表单中的文本字段进行控制验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i创建了一个表单,在表单中我有一个文本字段,只能接受字母表。我需要手动验证...

hi ,
i have created a form ,inside a form i have a text field which can accept only alphabets .i need the validation manually...

推荐答案

Google。 [ ^ ]


您可以简单地尝试做类似的事情。

You can simply try to do something like..
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    // allows only letters
    if (!char.IsLetter(e.KeyChar))
    {
        e.Handled = true;
    }
    else
    MessageBox.show("This is not a letter");
}



尝试申请。


Try to apply in your case.


在活动中添加此代码:



add this code in event:

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
     {

          if (char.IsNumber(e.KeyChar))
         {
             e.Handled = true;
         }

     }


这篇关于需要对表单中的文本字段进行控制验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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