I have a question, what event do we use for textbox in login?
I want to make a LoginForm in my program where in when I type the Username and Password to the TextBoxes, I will use ENTER(in keyboard) instead of clicking the button ‘Login’.
What events should I put these codes? :
If txtUser.Text <> UsernameTextBox.Text And txtPass.Text <> PasswordTextBox.Text Then
MsgBox("Wrong Username or Password!", MsgBoxStyle.Critical)
txtUser.Text = ""
txtPass.Text = ""
Else
ProgressBar1.Show()
LoadLabel.Show()
Timer1.Start()
End If
According to MSDN, the form’s
AcceptButtonproperty:To get the behavior you are looking for, just set the
AcceptButtonproperty on the form to the log in button (there’s an example in the link) and put the code above into the regularOnClickevent handler for the button.