How to Login a application by pressing Enter key in the Keyboard after entering username and password using windows forms in C#.net || Login application by pressing enter key from keyboard with out using mouse in windows forms C#.net


To login any application by pressing Enter key in the keyboard after entering username and password  for that first I am taking two labels, two textboxes and one login button for design.
The design is looks like below:



Then write the following code in Code behind side:
First write the code for login button as per your requirement
  private void btnLogin_Click(object sender, EventArgs e)
        {

         
            //Login Code


         }
First check enter key ASCII value with pressing key from keyboard.
Enter key ASCII value is 13.
To know all keyboard keys ASCII values Click Here.

Then write the following code in  password textbox key press event :
private void txtPassword_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar.Equals(Convert.ToChar(13)))
            {
                btnLogin_Click(sender, e);
            }
        }


Then run your application and give username and password then click enter key then automatically it will login without  using mouse. 



0 comments:

Post a Comment