Thursday, March 27, 2014

C# after enter text and press enter, then trigger a button click

  private void textBox_Enter(object sender, EventArgs e)
    {
        ActiveForm.AcceptButton = Button1; // Button1 will be 'clicked' when user presses return
    }

    private void textBox_Leave(object sender, EventArgs e)
    {
        ActiveForm.AcceptButton = null; // remove "return" button behavior
    }
http://stackoverflow.com/questions/2212237/c-how-to-make-pressing-enter-in-a-text-box-trigger-a-button-yet-still-allow-s
Form.CenterToScreen

No comments:

Post a Comment