C# tabindex - 泛化(桌面应用程序)
我有几个文本框。我想每次按 Enter 键时将用户指向下一个文本框。 文本框已正确设置 Tabindex。
我得到类似的信息:
private void textBox_Description_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
e.Handled = true;
setFocusOnNextElement(sender);
}
}
setFocusOnNextElement 应该是什么样子?如果我想让它变得通用。我可以解析每个控件,并找到接下来的内容,但我有一种感觉,这可以做得更好。
I have a few textboxes. I'd like to point the user each time to the next textbox, on pressing enter.
Textboxes have Tabindex set up correctly.
I got something like:
private void textBox_Description_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
e.Handled = true;
setFocusOnNextElement(sender);
}
}
How should setFocusOnNextElement look like? If i want to make it general. I could parse each control, and find what's next, but I have a feeling that this can be done nicer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不建议像您拥有的那样构造该函数,因为它要求参数是一个
对象
。然后像这样调用它:
I would not advise constructing the function just as you have it, as it would require that the parameter be an
object
.Then invoke it like this: