在文本框中的按键事件上显示错误消息 [英] show error message on keypress event in textbox

查看:56
本文介绍了在文本框中的按键事件上显示错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void txtzip_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (char.IsLetter(e.KeyChar))
            {
                MessageBox.Show("Hi");
            }
        }



当用户键入不符合以上条件但无法正常工作的错误内容时,我使用了上面的编码来显示消息.我还给出了keypreview = true



i used above coding to show message when user type wrong thing which is not match above condition but its not working ., i also given keypreview=true

推荐答案

您好,亲爱的,
使用此代码,它将起作用
Hello dear,
use this code, it will work
if (char.IsLetter(e.KeyChar))
            {
                MessageBox.Show("Hi");
            }



试试这个.

http://www.daniweb.com/software-development/vbnet/threads/114278/textbox-key-press-event [ ^ ]
Hi,
try This one.

http://www.daniweb.com/software-development/vbnet/threads/114278/textbox-key-press-event[^]


这篇关于在文本框中的按键事件上显示错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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