How to skip Validating after clicking on a Form's Cancel button

前端 未结 17 1201
一生所求
一生所求 2020-12-08 04:04

I use C#. I have a Windows Form with an edit box and a Cancel button. The edit box has code in validating event. The code is executed every time the edit box loses focus. Wh

17条回答
  •  死守一世寂寞
    2020-12-08 04:36

    If the validation occurs when the edit box loses focus, nothing about the the cancel button is going to stop that from happening.

    However, if the failing validation is preventing the cancel button from doing its thing, set the CausesValidation property of the button to false.

    Reference: Button.CausesValidation property

提交回复
热议问题