Keyup事件

编程入门 行业动态 更新时间:2024-10-23 02:05:20
本文介绍了Keyup事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经在C#中创建了一个表单,并且我试图让程序在按下特定按钮时执行某些操作。我做了以下工作: this.KeyUp + = new System.Windows.Forms.KeyEventHandler(this.POS_KeyU p); private void POS_KeyUp(object sender,System.Windows.Forms.KeyEventArgs e) { if(e.KeyValue.ToString()==" 123") { Update1.PerformClick(); } System.Windows.Forms.MessageBox.Show(e .KeyValue.To String()); } 然而这不起作用。我甚至没有收到消息框。任何人都可以帮忙吗?

Hi, I''ve created a form in C# and I am trying to get the program to do something when a particular button is pressed. I have done the following: this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.POS_KeyU p); private void POS_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if(e.KeyValue.ToString()=="123") { Update1.PerformClick(); } System.Windows.Forms.MessageBox.Show(e.KeyValue.To String()); } this however does not work. I don''t even get a message box. Can anyone help?

推荐答案

" 123"不是键盘上的键,至少不是我见过的任何键。 该事件用于捕获单个按键。您可以在此基础上跟踪一系列按键,但不能同时跟踪所有按键。 您的表单必须关注该事件才能触发。当你松开按钮时会触发,而不是按下它的按下 "123" is NOT a key on a keyboard, at least not on any I''ve seen. That event is used to capture individual key presses. You can build upon that to track a sequence of keypresses, but not all at once. Your form has to have the focus for that event to fire. And it will fire when you release the button, not on it''s press

123是F12 此外我的表格确实有焦点即使我松开按钮也没有任何反应。我试过按其他按钮但消息框甚至没有出现 123 is F12 Also my form does have the focus and nothing happens, even when I release the button. I''ve tried pressing other buttons but the messagebox doesn''t even come up

123是F12 此外,我的表格确实有焦点,没有任何反应,即使我释放按钮。我试过按其他按钮但消息框甚至没有出现 123 is F12 Also my form does have the focus and nothing happens, even when I release the button. I''ve tried pressing other buttons but the messagebox doesn''t even come up

你在哪里输入这段代码?

where are u entering this piece of code?

展开 | 选择 | Wrap | 行号

更多推荐

Keyup事件

本文发布于:2023-11-11 07:03:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577714.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   Keyup

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!