通过按Enter在TEXBOX中激活按钮
我是在编码中的新手,我试图通过按Enter来从文本框中激活我的按钮。我试图用Google获取答案,但Visual Studios表示它不起作用。 我在搜索答案时阅读的最常见的内容是下面的代码。现在问题是Visual Studios向我显示key Code
行作为错误。有人可以帮我弄清楚为什么这是错误的吗?
if (e.Keycode == Keys.Enter)
{
button1_Click(this, new EventArgs());
}
Im new here in Coding and im Trying to activate my button from a Textbox by pressing enter. I tried to google for the Answer but Visual Studios say it doesnt work.
The most common Thing i read while searching for an Answer was the code down below. Now the problem is Visual Studios shows me the Keycode
line as error. Can somebody help me figure out why its an Error?
if (e.Keycode == Keys.Enter)
{
button1_Click(this, new EventArgs());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
keydown
事件。您可能已经在代码中有类似的东西。它是通过使用设计器中的GUI选项或在编程上使用以下操作来完成
。
key代码
应用资本C拼写,即:key Code
。完整事件处理程序方法的示例:
KeyDown
event, in case you haven't.You might already have something like that in your code. It is done by either using the GUI options in the designer, or programatically using something like:
this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown);
In the event handler,
Keycode
should be spelled with capital C, i.e.:KeyCode
.An example for a complete event handler method: