0

With the following:

this.AcceptButton = this.OKButton;
this.OKButton.Enabled = false;

... will the OK button click handler still be invoked when the user presses Enter?

Aidan Ryan
  • 11,389
  • 13
  • 54
  • 86

3 Answers3

5

No, it won't be invoked.

Daniel LeCheminant
  • 50,583
  • 16
  • 120
  • 115
3

No, when the button is disabled, it will not activate and trigger that event.

-Adam

Adam Davis
  • 91,931
  • 60
  • 264
  • 330
1

AcceptButton/CancelButton just call the button's PerformClick() method... which doesn't run if the control is disabled.

Powerlord
  • 87,612
  • 17
  • 125
  • 175