This article introduces how to set the response event of pressing the Enter key on a window when using C#to program a form (winform).Or to respond to a button.

Press enter on the form,We can set the program to trigger some events.These events are bound through the form's acceptButton property.

In the form's load function, we set this.acceptbutton, where this represents the form object itself.The acceptbutton is the button that responds to the enter key.Its value is the name of a button type control in the current form.

private void form1_load (object sender, eventargs e)
 this.acceptbutton=btnmodify;//default enter key

At this point, we can press the Enter key in the form,The system will execute the onclick event function of the btnmodify link.If the onclick event does nothing,Then pressing enter will have no effect.

  • Previous The most concise C # barcode image ideas and examples in history
  • Next C # Socket Network Programming Example