C#如何实现在textBox1上敲回车时光标跳至button2 ?
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (textBox1.Text.Trim() != " ")
{
if //敲回车键 ....这里怎么写 ?
{
button2.Focus();
}
}
}
------解决方案--------------------if (e.KeyChar == 13)
------解决方案--------------------if (textBox1.Text.Trim() != " ")
{
if (e.KeyChar == (char)13)
{
button2.Focus();
}
}
------解决方案--------------------用Key_Down事件,别用Key_Press
------解决方案--------------------if (textBox1.Text.Trim() != null)
{
if (e.KeyCode==Keys.Enter )
{
textBox2.Focus();
}
}
------解决方案--------------------private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (textBox1.Text.Trim() != null)
{
if (e.KeyCode==Keys.Enter )
{
textBox2.Focus();
}
}
}