Click Event Not Firing - Cannot Change Focus - Cannot Close Form

Here is the reason:

When using data binding, when you enter a value in a data bound control, it first tries to validate entry and then if the entry was valid, data binding will put the value in data source, but if a validation error occurs validation returns false and your control goes to invalid mode.

When a child control of form didn't validate, by default you can not change focus from invalid control.

Click on a button by default causes validation of the control that are losing the focus, so you can't click on button, as you see your button reflect to mouse but not actually click.

The same problem will happen if you handle Validating event of a control like TextBox and set e.cancel = true.

Here is the fix:

you can fix this behavior using either of following options:

  • Set CausesValidation property of your button to false
  • Set AutoValidate property of your form to AutoValidate.EnableAllowFocusChange