如何使输入的文本框充当TAB键文本框、TAB

2023-09-03 10:53:48 作者:怕冷的小高冷

我有几个文本框。我想打回车键充当选项卡。所以,当我将在一个文本框,pressing输入将移动到我的下一个。你能告诉我如何实现此方法无需添加任何code文本框类中(无覆盖等如果可能的话)?

I've several textboxes. I would like to make the Enter button act as Tab. So that when I will be in one textbox, pressing Enter will move me to the next one. Could you please tell me how to implement this approach without adding any code inside textbox class (no override and so on if possible)?

推荐答案

下面是code,我通常使用。 它必须是在KeyDown事件。

Here is the code that I usually use. It must be on KeyDown event.

if (e.KeyData == Keys.Enter)
{
    e.SuppressKeyPress = true;
    SelectNextControl(ActiveControl, true, true, true, true);
}