具有自动完成功能的文本框不会执行key_press事件

问题描述 投票:0回答:1

我有一个带有KeyPress事件的文本框,当按下Enter键时它会更改为其他文本框,并且直到我从Visual Studio的属性面板中添加了自动完成属性,例如:

AutoCompleteCustomSource:集合

[自动完成模式:建议添加

AutoCompleteSource:CustomSource

现在自动完成功能有效,但是当我按Enter时,它不会更改为另一个文本框。

c# visual-studio autocomplete textbox
1个回答
0
投票

也许您可以改用事件KeyDown。在我的测试中效果很好。

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        textBox2.Focus();
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.