首页  编辑  

TextBox禁止输入某个字符,消除输入无效字符的警告声

Tags: /C#/界面处理/TextBox_RichEdit/   Date Created:

private void textBox1_KeyPress( object sender, KeyPressEventArgs e)

{

       e . Handled = char . ToUpper(e . KeyChar) == 'D' ;

}

// 消除字符的警告声

private void textBox1_KeyPress ( object sender , KeyPressEventArgs e)

{

   e . Handled = (e . KeyChar == ( char ) 27 ) || (e . KeyChar == ( char ) 13 );

}