一个输入账号的textbox不能输入汉字,得到的办法:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = !char.IsDigit(e.KeyChar);
}
用这种判断是可以禁止输入非数字,但是我退格和回车都没反应了,求助哦。
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = !char.IsDigit(e.KeyChar);
}
用这种判断是可以禁止输入非数字,但是我退格和回车都没反应了,求助哦。
禁止输入汉字不用这么麻烦
<asp:TextBox style="ime-mode:disabled" ID="TextBox1" runat="server"></asp:TextBox>
ime-mode
学习 这个是ASP网页的,Form里面也一样么
winformtextbox有个ImeMode属性。设为disable
{
e.Handled = !((char.IsDigit(e.KeyChar))||(char.IsContro
(e.KeyChar)));
}小弟研究了一番,这是我改了的。
谢谢各位的答案,又学到了不少。