This article shows you how to implement the carriage return event and the Enter Trigger button in C # WinForm perfect notation
We often have to implement the Enter (Enter) submission feature in C # WinForm, which is quicker than pressing the button trigger manually.
To complete the carriage return Press the button function, only two steps
1. Find the carriage return event
2. Call the corresponding button event in the Carriage return event function
Let's take a look at each:
1. Carriage return Event: We generally use the KeyDown event. Almost all of the components have KeyDown events. The components we choose here may be Form1 or other components such as tabpage1 or DataGridView, which are to be found right here.
2. Call the corresponding button event in the Carriage return event function
The KeyDown event is not specifically set for carriage return, is for all buttons, we also need to make a judgment, and then call the corresponding button event, 1 and 22 steps throughout the code as follows:
private void Form1_keydown (object sender, KeyEventArgs e)
{
if (E.keycode = = Keys.enter)//Determine Enter
{
This.button1_click (sender, E);//Trigger button Event
}
}
After testing, perfect error-free, press ENTER in Form1, Button1 Click event will start execution.
Enter Departure events (+ favorites) in C #