限制TextBox只容許輸入數字和字母

設置TextBox控件屬性blog

ImeMode=Disable
ShortcutsEnabled=False

  

VB.NETclass

 Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
       If e.KeyCode = Keys.Space Then e.SuppressKeyPress = True
    End Sub

C#object

private void TextBox1_KeyDown(object sender, KeyEventArgs e)
{
	if (e.KeyCode == Keys.Space)
	e.SuppressKeyPress = true;

}
相關文章
相關標籤/搜索