如何在 Windows 窗体应用程序中创建 Alt 快捷方式? [英] How can you create Alt shortcuts in a Windows Forms application?

查看:54
本文介绍了如何在 Windows 窗体应用程序中创建 Alt 快捷方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的 Windows 窗体应用程序中的某些控件创建键盘快捷键.

I'd like to create keyboard shortcuts for some controls in my Windows Forms application.

示例:

注意下划线 F E V P B.

Notice the underlined, F E V P B.

我有一个标签和一个文本框控件.我想将 Alt 键盘快捷键与标签和文本框相关联.因此,如果有人按下 Alt + B,焦点将被赋予相关的文本框.有没有办法创建这个关联?

I have a label and a textbox control. I'd like to associate that Alt keyboard shortcut to the label and the textbox. So if someone presses Alt + B, focus is given to the associated textbox. Is there a way to create this association?

推荐答案

当标签通过按下其加速键获得焦点时(使用 & 设置),它将焦点转发到下一个控件在 Tab 键顺序中,因为标签不可编辑.您需要将文本框作为 Tab 键顺序中的下一个控件.

When the label receives focus from pressing its accelerator key (set using the &), it forwards the focus to the next control in the tab order, since labels are not editable. You need the textbox to be next control in the tab order.

要查看和更正表单的 Tab 键顺序,请使用 IDE 中的查看 + 选项卡顺序"命令.使用 TabPages 或其他容器会向 Tab 键顺序添加一层嵌套(例如,1.11.2 而不仅仅是 12),但如果标签和文本框在同一个容器中,那么正确设置应该不会太难.

To view and correct the tab order of your form, use the View + Tab Order command in the IDE. Using TabPages or other containers adds a level of nesting to the tab order (e.g., 1.1, 1.2 instead of just 1 and 2), but if the label and textbox are within the same container it shouldn't be too hard to set properly.

这篇关于如何在 Windows 窗体应用程序中创建 Alt 快捷方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆