表单keyPress事件正常运行:
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= 30 && e.KeyChar <= 127) || (e.KeyChar >= 10 && e.KeyChar <= 31))
{
//do something
MessageBox.Show("asdasd");
}
}
但是如果我开始更新例如组合框文本的线程,那么KeyPress事件根本不起作用!
public void startcbadd()
{
this.Invoke(new MethodInvoker(delegate ()
{
comboBox1.Text = "test";
}));
}
private void button1_Click(object sender, EventArgs e)
{
t = new Thread(startcbadd);
t.Start();
}
你有什么想法来解决它吗?