简体   繁体   English

KeyPress 或 keyup 不触发

[英]KeyPress or keyup not firing

ok i have ac# 2017 net net windows form frmFS the KeyPress, KeyDown or Keyup are not firing.好的,我有 ac# 2017 net net windows form frmFS KeyPress、KeyDown 或 Keyup 没有触发。 I created a new project with select the events for keypress, keydown and keyup (put a messageboc.show("bla") in each function it works but my current project nothing. how can i trace the issue.我创建了一个新项目,为 keypress、keydown 和 keyup 选择事件(在它工作的每个函数中放置一个 messageboc.show("bla") ,但我当前的项目什么都没有。我怎样才能追踪这个问题。

Let's assume you are using a text box for your KeyDown , KeyUp and KeyPress events.假设您正在为KeyDownKeyUpKeyPress事件使用文本框。

In visual studio in the designer select the text box (or control you are referring to).在设计器中的 Visual Studio 中选择文本框(或您所指的控件)。

Then in the properties pane, select the Events tab.然后在属性窗格中,选择“事件”选项卡。

Then look for the KeyDown , KeyPress and KeyUp events.然后查找KeyDownKeyPressKeyUp事件。

If the values next to the events are blank then the event in not linked to the control.如果事件旁边的值为空,则事件未链接到控件。

在此处输入图片说明

you can double click in the value column to generate the code for the event, or you can see if the event appears in the drop down (if it already exists).您可以双击值列以生成事件的代码,或者您可以查看该事件是否出现在下拉列表中(如果它已经存在)。

在此处输入图片说明

in the code for the form the event method should be visible.在表单的代码中,事件方法应该是可见的。

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
 //code here..
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM