msdn学习中心有一段小例子。 是用来记录按键次数的。我把它稍微做了一些改动,就可以屏蔽键盘输入了。
不过只能屏蔽普通输入,一些控制键如tab,上下左右等是不能屏蔽的
public class myKeyPressClass
{
static long keyPressCount = 0 ;
static long backspacePressed = 0;
static long returnPressed = 0 ;
static long escPressed = 0 ;
private TextBox textBox1 = new TextBox();
private void myKeyCounter(object sender, KeyPressEventArgs ex)
{
switch(ex.KeyChar)
{
// Counts the back