- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的 WinForm 上有一个确定按钮。
我想提供点击确定按钮的选项,也可以通过输入按。
这是我的代码:
void MyFormKeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar==13)
{
//What have I to do in order to call ButtonOK click event?
}
}
谢谢
最佳答案
您可以设置 Form.AcceptButton按钮的表单属性。
This property enables you to designate a default action to occur when the user presses the ENTER key in your application. The button assigned to this property must be an IButtonControl that is on the current form or located within a container on the current form.
例子:
那么你的表单名称是form1,你的按钮是button1
form1.AcceptButton = button1;
应该做你想做的。
或者您可以使用您现有的代码并调用
yourButton.PerformClick();
关于c# - KeyPressed 事件调用其他事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21304741/
这是我的代码: $( '#Example' ).on( "keypress", function( keyEvent ) { if ( keyEvent.which != 44 ) {
自从我切换到 MAC 以来,我一直讨厌这样一个事实,即我必须使用 cmd+tab 的 alt 键来隐藏窗口。 我知道有一些应用程序(如 witch )可以替代 cmd+tab 功能,但我喜欢当前的界面
我希望在文本框上按键时运行一个函数,因此我有以下代码: $("input[x]").keypress(function() { DoX(); }) 这工作正常,但在我的函数中我
我有一个场景,我想通过进行 Http REST 调用来获取匹配的字符串,将每次击键时输入框中出现的字符串发送到服务器。但它没有按我的预期工作,例如,假设输入框中的当前值为“modul”,如果我在“mo
我刚刚开始使用 p5.js,我喜欢它的简单性,但有一点我无法掌握。 我设置了以下Fiddle : function Player(location, width, height, speed, wei
这里有两个类: public class Cls implements Runnable, KeyListener Thread t; Object obj; public Cls(Thing obj
我将一些程序从学校的计算机(Mac)传输到我的家用电脑。进入我的计算机后,我注意到按键现在在每个程序中都不起作用。我花了几个小时试图找出 KeyPressed 不起作用的原因。两台电脑都使用Eclip
我正在用java为自己制作一个俄罗斯方 block 克隆,作为一个学习项目。然而,我现在陷入了获取左右移动棋子的输入部分。我不确定问题是否出在我的方法中,或者问题出在未调用的 keyPressed 方
基本上我必须为一个项目使用 Processing(并非出于选择)并且遇到了关于一次按下多个键的问题。在 keyPressed() 函数中,我有多个条件,每个都将一个键映射到一个 Action 。这一切
目前我正在使用 jQuery,尤其是该函数 keypress() 这个函数可以告诉我很多关于按下哪个键、在哪里以及何时按下的信息。但什么时候是我的问题:所以这段代码... $(document).ke
我是 JavaScript 新手,在使用“keypress”事件时遇到问题;我目前正在做一个小的跳跃脚本测试,“keydown”和“keyup”事件都起作用,但“keypress”不起作用(我尝试在事
我试图在每次字段更改时执行一个函数。首先,我使用一个简单的 textarea 和一个 div: $("#stuff").keypress(function () { $(
嘿伙计们,可能是一个简单的问题,但在网上找不到任何东西。 我有一个包含搜索结果的列表,我希望能够使用向上和向下键在列表中导航。 if (e.keyCode == 40) { //down
我当前正在通过 .click 事件添加输入,然后想要监听此输入上发生的任何按键。但是,附加内容在插入后不会触发任何事件(即模糊、按键、焦点)。有没有人有什么建议?提前致谢! $("#recipient
我想知道是否可以在表单级别当表单中有控件时处理 KeyPress 事件。 当窗体上没有控件时我可以实现这一点,但是当我添加一些东西时,比如按钮,窗体失去焦点并且我无法将其返回,即使使用 Me.Focu
情况:表单有一个文本框,用户必须在其中键入一些文本。此文本框有一个 KeyPress 事件,在该事件中,窗体的文本属性更改为用户在每次击键时键入的文本。 这是文本框按键事件的代码: private
我正在开发一个应用程序并卡住了。我有一个普通的简单按钮。我想要做的是,如果我单击此按钮,它的行为就像您在软键盘上按空格键一样。 我该怎么做。一定有办法,因为您可以开发软键盘。 所以重复 xP 如果我按
在这个页面上: https://subnetipv4.com/ 如果您单击“IP 地址”列中的任何输入框,然后按“.”或“/”键(句点或斜杠),它会跳转到下一个输入框。 或者至少,它在桌面浏览器上是这
这段代码构建正确,一切似乎都有效,但 key 什么也没做。我认为要么是 Action 监听器,要么是椭圆没有更新。我正在尝试通过初学者 java 游戏编程。我确信这很容易,但我没有捕获它。如果这有所作
我在 jTable 中有一系列文本框和组合框。我使用框中的输入来过滤 JPQL 查询的结果,这些结果显示在 jTable 上。现在,想法是使该过程自动化,以便每次用户在框中键入一个字符时,应用程序都会
我是一名优秀的程序员,十分优秀!