110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication29
{
public partial class Form1 : Form
{
Keys Old = Keys.None;
public Form1()
{
InitializeComponent();
TextBox TB = new TextBox();
TB.Parent = this;
TB.KeyDown += new KeyEventHandler(TB_KeyDown);
TB.KeyUp += new KeyEventHandler(TB_KeyUp);
}
void TB_KeyUp(object sender, KeyEventArgs e)
{
Old = Keys.None;
}
void TB_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Old)
e.SuppressKeyPress = true;
else
Old = e.KeyData;
}
}
}