我需要有关C#的解决方案 [英] I need a solution about C#

查看:86
本文介绍了我需要有关C#的解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows应用程序的C Sharp中委派Enter键?

How to delegate an enter key in C sharp for windows application?

推荐答案

查看此链接

http://msdn.microsoft.com/en-us/library/ms171548.aspx [ ^ ]
Check out this link

http://msdn.microsoft.com/en-us/library/ms171548.aspx[^]


有一种特殊情况专门用于Enter和Escape:

您需要一个或两个按钮,一个代表按下Enter键时的动作,另一个代表按下Escape键时的动作.可以按通常的方式来分配操作,即通过Click事件来分配.

There is one special case working specifically with Enter and Escape:

You need one or two buttons, one representing the action when Enter is pressed, another when Escape is pressed. The actions could be assigned in a usual way, i.e. via Click events.

Button btnEscape, btnEnter;
//...
MyForm.AcceptButton = btnEnter;
MyForm.CancelButton = btnEscape;



MyForm的这两个属性,当分配给按钮时,将导致任何子控件(所有递归子控件)预览转义和/或输入键盘输入并调用相应的相应操作(一个或多个)按钮.

如果您的表单是模式表单,则通常使用此表单(使用ShowDialog方法显示).如果为按钮分配了ModalResult,则其动作将是表单的ModalResult,但是您不必使用此功能,因为您还可以简单地以所需的方式编写Click事件处理程序.但是,打算使用ModalResult.



These two properties of MyForm, when assigned to buttons, will cause any of the child controls (all recursive children) preview Escape and/or Enter keyboard input and invoke corresponding action(s) of the appropriate button(s).

Usually this is used if your form is modal (shown using ShowDialog method). If the button is assigned a ModalResult, its action will be a ModalResult of the form, but you do not have to use this feature, because you can also simply write Click event handler the way you want. Using ModalResult, however, is the intended usage.


Here[^]

Hope this will help you.


这篇关于我需要有关C#的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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