如何在c#中设置快捷键功能区菜单 [英] How to set shortcut keys Ribbon Menu in c#

查看:149
本文介绍了如何在c#中设置快捷键功能区菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何在c#windows应用程序中设置快捷键功能区菜单



谢谢,

Pawan

Hi all,
How to set shortcut key Ribbon menu in c# windows application

Thanks,
Pawan

推荐答案

您只需在子菜单名称中键入&前面的char,如下一个示例所示:&Open,E&xit 。
You have only to type & in front of the char from the sub-menu name, like in the next examples: "&Open", "E&xit".


在表格的缩写中添加以下代码



public Button SaveButton = new Button();

public Button CloseButton = new Button();



this.AcceptButton = SaveButton;

this.CancelButton = CloseButton;



this.SaveButton.Click + = new System.EventHandler(this.rbnbtnSave_Click);

this.CloseButton.Click + = new System.EventHandler( this.rbnbtnClose_Click);





//this.rbnbtnSave_Click - 这个功能区ok按钮点击事件

// this.rbnbtnClose_Click - 这个功能区取消按钮点击事件
Add the following code in form's constrictor

public Button SaveButton = new Button();
public Button CloseButton = new Button();

this.AcceptButton = SaveButton;
this.CancelButton = CloseButton;

this.SaveButton.Click += new System.EventHandler(this.rbnbtnSave_Click);
this.CloseButton.Click += new System.EventHandler(this.rbnbtnClose_Click);


//this.rbnbtnSave_Click --this the ribbon ok button click event
// this.rbnbtnClose_Click --this the ribbon Cancelbutton click event


Se在菜单上添加你要指定的快捷方式。



右键单击它并点击属性。



在文本字段中,在要创建快捷方式的字符前,使用&这个符号写下要显示的菜单名称。



ex:假设您有一个名为file的菜单。并且你想在f上创建一个快捷键。

然后:选择文件菜单 - 转到属性 - 在文本字段中将菜单名称设置为

'&File'没有'标志。它会用F创建快捷键。



如果你想在运行时看到这个快捷键,只需按下键盘上的ctrl(Control)按钮。将显示所有快捷键。
Select the Menu which you want to assign shortcut.

right click on it and click on properties.

In the Text field, write the name of the menu which you want to show with '&' this sign before the character on which you want to make the shortcut.

ex : suppose you have a menu called file. and you want to make a shortcut key on f.
then : select the file menu - go to properties - in the text field set the menu name as
'&File' without ' sign. it will create the shortcut key with F.

when you want to see this shortcut in run time just press the ctrl (Control) button in keyboard. all the shortcuts key will be displayed.


这篇关于如何在c#中设置快捷键功能区菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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