键盘操作菜单的代码 [英] code for menus operation by keyboard

查看:91
本文介绍了键盘操作菜单的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过键盘进行菜单操作的代码.请提供代码.

I need code for menu operation by keyboard. Please provide the code for it.

推荐答案

您无需编写任何代码即可完成此操作,它以两种方式内置于框架中:

1)如果在菜单文本中的单个字符(例如&File")前添加&"字符,则该字符将带有下划线并由[ALT] +该字符([ALT] + F用于标准菜单中的文件".正如您所期望的,这也适用于子菜单.

2)对于可在菜单栏范围内使用的快捷键,请选择该项目并编辑ShortcutKeys属性.将其设置为[F2],然后F2键将操作整个表单中的菜单项.
You don''t need to write any code to do this, it is built into the framework in two ways:

1) If you add an ampersand character ''&'' in front of a single character in your menu text ("&File" for example) the character will be underlined and activated by [ALT] + that character ([ALT]+F for "File" in a standard menu). This also works for sub-menus, as you would expect.

2) For short cut keys that work throughout the scope of the menu bar, select the item and edit the ShortcutKeys property. Set it to [F2] and the F2 key will action the menu item throughout the form.


这篇关于键盘操作菜单的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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