คำตอบ Use "ENTER" key for button

  • 20 สิงหาคม 2555 17:22
     
      มีโค้ด

    Hi, 

    I have a a form which has one button.  I would like to use the "ENTER" key instead of clicking on the button to log in.

    Here's the button code:

    private void button1_Click(object sender, EventArgs e)
            {
                if (username.Text == "test" && password.Text == "test")
                {
                    this.Hide();
                    Form1 fr = new Form1();
                    fr.Show();
                }
    
                else
                {
                    MessageBox.Show("Incorrect Name or Password");
                }
            }

ตอบทั้งหมด