If you want to do something then you need to handle the event that is raised at the appropriate time. What event is raised when the user hits the Enter key? That's the event you need to handle and then you need to write the appropriate code to do what you want to do.
Please refrain from asking for code on the forums unless you are willing to pay the developers for their work. If you have code that you have written yourself, then you need to post that code here and explain what it is you're trying to do, and what problem(s) you are experiencing with that code. Also be sure to post your code in code tags when posting to the forums, as this helps keep the code formatting and makes for easier readability.
A general key up event looks like the below. You can also invoke click on the button which would hold your action for logging in, if the enter key is pressed. Reading the keyeventargs we can check what key was pressed and in this case if it is enter key, we perform click on our button1 which would then log you in. You need to write your own code for that. These are the events you'd use, keep in mind that its generally frowned upon to ask for code on any forum :
private void textBox1_KeyUp(object sender, KeyEventArgs e)
if (e.KeyCode == Keys.Enter) button1.PerformClick();
private void button1_Click(object sender, EventArgs e)
MessageBox.Show("Called by key press or clicked");
The way to get those events into your code file is to do as i I have in the gif, so don't just copy and paste :
Or alternatively write your own events and handlers yourself, which is what I generally do. Since I don't like using or working with the designer, and I prefer to hand-code my forms. But that's just personal preference, since I have trust issues with the designer generated code.
No need to quote the person directly above you, especially in whole. Quotes like that just takes up massive scrolling spaces for people browsing on mobiles. Use the quick reply area at the bottom instead.