带有 2 个组框的 Enter 上的下一个文本框
Next Textbox on Enter with 2 group boxes
我有两个组框,第一个组框有 3 个文本框,第二个组框有 1 个文本框。我添加了这段代码:
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyData == Keys.Enter))
{
SelectNextControl(ActiveControl, true, true, true, true);
}
}
但是enter只在第一个组框起作用,跳过按钮,跳过第二个组框。
我该怎么办?
如MSDN所述:
The SelectNextControl method activates the next control in the tab order if the control's Selectable style bit is set to true in ControlStyles, it is contained in another control, and all its parent controls are both visible and enabled.
您可以在设计器的 属性 TabIndex
上找到您的控件(文本框的)标签顺序号。
我有两个组框,第一个组框有 3 个文本框,第二个组框有 1 个文本框。我添加了这段代码:
private void FormMain_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyData == Keys.Enter))
{
SelectNextControl(ActiveControl, true, true, true, true);
}
}
但是enter只在第一个组框起作用,跳过按钮,跳过第二个组框。 我该怎么办?
如MSDN所述:
The SelectNextControl method activates the next control in the tab order if the control's Selectable style bit is set to true in ControlStyles, it is contained in another control, and all its parent controls are both visible and enabled.
您可以在设计器的 属性 TabIndex
上找到您的控件(文本框的)标签顺序号。