在文本框中的按键事件上显示错误消息
问题描述:
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[^]