在我目前的情况下如何停止 keydown 事件?
private void button1_Click(object sender, EventArgs e)
{
textBox1.Focus();
textBox1.KeyDown += new KeyEventHandler(MyKeyPress);
}
public void MyKeyPress(object sender, KeyEventArgs e)
{
e.SuppressKeyPress = true;
string first = e.Modifiers.ToString();
if (first != "None")
{
if ((e.KeyCode != Keys.ShiftKey) && (e.KeyCode != Keys.Alt) && (e.KeyCode != Keys.ControlKey))
{
textBox1.Text = e.Modifiers.ToString() + " & " + e.KeyCode.ToString();
}
}
else
{
textBox1.Text = e.KeyCode.ToString();
}
e.Handled = true;
}
如您所见-当用户单击按钮时触发事件..但是如何在第一次输出后停止它?
e.Handled = true;
根本没有帮助