我试过这段代码:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (Convert.ToInt32(e.KeyChar) == 13)
{
MessageBox.Show(" Enter pressed ");
}
}
还有这个:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Enter))
{
MessageBox.Show(" Enter pressed ");
}
}
还有这个:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Keys.Enter)
{
MessageBox.Show(" Enter pressed ");
}
}
但他们没有工作......
当我写东西并按Enter时,它不起作用。它只突出显示我的文字。