当我单击Enter时如何运行按钮? [英] how to run a button when i click enter ?

查看:63
本文介绍了当我单击Enter时如何运行按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始学习c#,有人可以告诉我该怎么做吗?

解决方案

您需要做的只是检查 event.keyCode == 13 和在按钮上执行 .click() 操作.


看一下以下链接..

堆栈溢出链接 [ ^ ]
BR//
例如,Harsha


我假设您想在用户按下文本框上的Enter时单击"按钮,并且您正在使用winforms. >
您需要处理文本框的KeyDown或KeyUp事件,并根据所按下的键调用按钮的PerformClick()事件.单击该按钮还是其他?请解释.


I am new at learning c#, can anyone tell me how I can do this ?

解决方案

All you need to do is to check if event.keyCode == 13 and perform the .click() operation on the button.


Take a look at the following link..

Stack Overflow Link[^]
BR//
Harsha


I''m assuming you want to "click" a button when the user presses enter on a textbox, for example, and that you''re working with winforms.

You need to handle the KeyDown or KeyUp event of the textbox and depending on the key pressed call the PerformClick() event of the button.


Do your want to work on Button_Click() event on clicking the button or something else? Please explain.


这篇关于当我单击Enter时如何运行按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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